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:09:54 -0500
commit30af92e78d36523f8012da5eb9aee16687d8fe61 (patch)
tree1f84280f76613282c8a81dc9b7aaf2b738201dfa /res/res_pjsip_path.c
parent7580a736bb30577d7557aac9165894dc9f9583e6 (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 47d6a7906..20c9d4366 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;