summaryrefslogtreecommitdiff
path: root/res/res_pjsip_path.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2016-08-29 18:08:22 -0500
committerRichard Mudgett <rmudgett@digium.com>2016-09-09 17:13:02 -0500
commitba362822f34e1967e5e15a0e81bab2f5981b014a (patch)
tree2a29699f8901f55e40b7f9270532f4b8ec405455 /res/res_pjsip_path.c
parent9d54dd04bbdad6849aee77536ab12c5fa6620680 (diff)
res_pjsip: Add ignore_uri_user_options option.
This implements the chan_sip legacy_useroption_parsing option but with a better name. * Made the caller-id number and redirecting number strings obtained from incoming SIP URI user fields always truncated at the first semicolon. People don't care about anything after the semicolon showing up on their displays even though the RFC allows the semicolon. ASTERISK-26316 #close Reported by: Kevin Harwell Change-Id: Ib42b0e940dd34d84c7b14bc2e90d1ba392624f62
Diffstat (limited to 'res/res_pjsip_path.c')
-rw-r--r--res/res_pjsip_path.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/res/res_pjsip_path.c b/res/res_pjsip_path.c
index 2dde7323e..e170a750d 100644
--- a/res/res_pjsip_path.c
+++ b/res/res_pjsip_path.c
@@ -40,7 +40,8 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri
char *configured_aors, *aor_name;
pjsip_sip_uri *sip_uri;
char *domain_name;
- RAII_VAR(struct ast_str *, id, NULL, ast_free);
+ char *username;
+ struct ast_str *id = NULL;
if (ast_strlen_zero(endpoint->aors)) {
return NULL;
@@ -49,6 +50,14 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri
sip_uri = pjsip_uri_get_uri(uri);
domain_name = ast_alloca(sip_uri->host.slen + 1);
ast_copy_pj_str(domain_name, &sip_uri->host, sip_uri->host.slen + 1);
+ username = ast_alloca(sip_uri->user.slen + 1);
+ ast_copy_pj_str(username, &sip_uri->user, sip_uri->user.slen + 1);
+
+ /*
+ * We may want to match without any user options getting
+ * in the way.
+ */
+ AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(username);
configured_aors = ast_strdupa(endpoint->aors);
@@ -60,15 +69,16 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri
continue;
}
- if (!pj_strcmp2(&sip_uri->user, aor_name)) {
+ if (!strcmp(username, aor_name)) {
break;
}
- if (!id && !(id = ast_str_create(sip_uri->user.slen + sip_uri->host.slen + 2))) {
- return NULL;
+ if (!id && !(id = ast_str_create(strlen(username) + sip_uri->host.slen + 2))) {
+ aor_name = NULL;
+ break;
}
- ast_str_set(&id, 0, "%.*s@", (int)sip_uri->user.slen, sip_uri->user.ptr);
+ ast_str_set(&id, 0, "%s@", username);
if ((alias = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "domain_alias", domain_name))) {
ast_str_append(&id, 0, "%s", alias->domain);
ao2_cleanup(alias);
@@ -77,10 +87,10 @@ static struct ast_sip_aor *find_aor(struct ast_sip_endpoint *endpoint, pjsip_uri
}
if (!strcmp(aor_name, ast_str_buffer(id))) {
- ast_free(id);
break;
}
}
+ ast_free(id);
if (ast_strlen_zero(aor_name)) {
return NULL;