From 30af92e78d36523f8012da5eb9aee16687d8fe61 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Mon, 29 Aug 2016 18:08:22 -0500 Subject: 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 --- res/res_pjsip_messaging.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'res/res_pjsip_messaging.c') diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c index 4e5ad2652..07869052d 100644 --- a/res/res_pjsip_messaging.c +++ b/res/res_pjsip_messaging.c @@ -133,6 +133,12 @@ static struct ast_sip_endpoint* get_outbound_endpoint( } else if ((aor_uri = strchr(name, '@'))) { /* format was 'endpoint@' - don't use the rest */ *aor_uri = '\0'; + + /* + * We may want to match without any user options getting + * in the way. + */ + AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(name); } /* at this point, if name is not empty then it @@ -448,6 +454,12 @@ static enum pjsip_status_code rx_data_to_ast_msg(pjsip_rx_data *rdata, struct as sip_ruri = pjsip_uri_get_uri(ruri); ast_copy_pj_str(exten, &sip_ruri->user, AST_MAX_EXTENSION); + /* + * We may want to match in the dialplan without any user + * options getting in the way. + */ + AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(exten); + endpt = ast_pjsip_rdata_get_endpoint(rdata); ast_assert(endpt != NULL); @@ -528,7 +540,7 @@ static void msg_data_destroy(void *obj) static struct msg_data* msg_data_create(const struct ast_msg *msg, const char *to, const char *from) { - char *tag; + char *uri_params; struct msg_data *mdata = ao2_alloc(sizeof(*mdata), msg_data_destroy); if (!mdata) { @@ -553,9 +565,14 @@ static struct msg_data* msg_data_create(const struct ast_msg *msg, const char *t return NULL; } - /* sometimes from can still contain the tag at this point, so remove it */ - if ((tag = strchr(mdata->from, ';'))) { - *tag = '\0'; + /* + * Sometimes from URI can contain URI parameters, so remove them. + * + * sip:user;user-options@domain;uri-parameters + */ + uri_params = strchr(mdata->from, '@'); + if (uri_params && (uri_params = strchr(mdata->from, ';'))) { + *uri_params = '\0'; } return mdata; } -- cgit v1.2.3