[Asterisk-code-review] res pjsip caller id.c: Truncate cid num at first semicolon. (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Thu Sep 8 19:23:13 CDT 2016


Richard Mudgett has uploaded a new change for review.

  https://gerrit.asterisk.org/3846

Change subject: res_pjsip_caller_id.c: Truncate cid_num at first semicolon.
......................................................................

res_pjsip_caller_id.c: Truncate cid_num at first semicolon.

ASTERISK-26316
Reported by: Kevin Harwell

Change-Id: I0ad6bd64889af888358b12bde85563a040197f24
---
M res/res_pjsip_caller_id.c
1 file changed, 18 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/46/3846/1

diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 4d9f092..c3aa338 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -46,11 +46,29 @@
 	char cid_num[AST_CHANNEL_NAME];
 	pjsip_sip_uri *uri;
 	pjsip_name_addr *id_name_addr = (pjsip_name_addr *) hdr->uri;
+	char *semi;
 
 	uri = pjsip_uri_get_uri(id_name_addr);
 	ast_copy_pj_str(cid_name, &id_name_addr->display, sizeof(cid_name));
 	ast_copy_pj_str(cid_num, &uri->user, sizeof(cid_num));
 
+	/* Always truncate caller-id number at a semicolon. */
+	semi = strchr(cid_num, ';');
+	if (semi) {
+		/*
+		 * We need to be able to handle URI's looking like
+		 * "sip:1235557890;phone-context=national at x.x.x.x;user=phone"
+		 *
+		 * Where the uri->user field will result in:
+		 * "1235557890;phone-context=national"
+		 *
+		 * People don't care about anything after the semicolon
+		 * showing up on their displays even though the RFC
+		 * allows the semicolon.
+		 */
+		*semi = '\0';
+	}
+
 	ast_free(id->name.str);
 	id->name.str = ast_strdup(cid_name);
 	if (!ast_strlen_zero(cid_name)) {

-- 
To view, visit https://gerrit.asterisk.org/3846
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ad6bd64889af888358b12bde85563a040197f24
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>



More information about the asterisk-code-review mailing list