summaryrefslogtreecommitdiff
path: root/res/res_pjsip_caller_id.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2014-08-27 15:39:35 +0000
committerKinsey Moore <kmoore@digium.com>2014-08-27 15:39:35 +0000
commitbf850181076c786d2c9e5e7f23e205547c7140cb (patch)
tree3a384bb94539e77298c351ae79dcff9453bc0b25 /res/res_pjsip_caller_id.c
parentd199536a04690e3034d02243e197071d70fc4f9c (diff)
CallerID: Fix parsing of malformed callerid
This allows the callerid parsing function to handle malformed input strings and strings containing escaped and unescaped double quotes. This also adds a unittest to cover many of the cases where the parsing algorithm previously failed. Review: https://reviewboard.asterisk.org/r/3923/ Review: https://reviewboard.asterisk.org/r/3933/ ........ Merged revisions 422112 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 422113 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 422114 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 422154 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@422158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_caller_id.c')
-rw-r--r--res/res_pjsip_caller_id.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 64940d181..376493168 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -404,7 +404,11 @@ static void modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const st
id_uri = pjsip_uri_get_uri(id_name_addr->uri);
if (id->name.valid) {
- pj_strdup2(pool, &id_name_addr->display, id->name.str);
+ int name_buf_len = strlen(id->name.str) * 2 + 1;
+ char *name_buf = ast_alloca(name_buf_len);
+
+ ast_escape_quoted(id->name.str, name_buf, name_buf_len);
+ pj_strdup2(pool, &id_name_addr->display, name_buf);
}
if (id->number.valid) {
@@ -438,7 +442,11 @@ static pjsip_fromto_hdr *create_new_id_hdr(const pj_str_t *hdr_name, pjsip_tx_da
id_uri = pjsip_uri_get_uri(id_name_addr->uri);
if (id->name.valid) {
- pj_strdup2(tdata->pool, &id_name_addr->display, id->name.str);
+ int name_buf_len = strlen(id->name.str) * 2 + 1;
+ char *name_buf = ast_alloca(name_buf_len);
+
+ ast_escape_quoted(id->name.str, name_buf, name_buf_len);
+ pj_strdup2(tdata->pool, &id_name_addr->display, name_buf);
}
pj_strdup2(tdata->pool, &id_uri->user, id->number.str);