]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Correct RPID parsing for unquoted display-name.
authorWalter Doekes <walter+asterisk@wjd.nu>
Tue, 26 Feb 2013 19:34:59 +0000 (19:34 +0000)
committerWalter Doekes <walter+asterisk@wjd.nu>
Tue, 26 Feb 2013 19:34:59 +0000 (19:34 +0000)
Parsing Remote-Party-ID will now succeed if display-name is of the
*(token LWS) kind and not just the quoted-string kind.

Review: https://reviewboard.asterisk.org/r/2341/
........

Merged revisions 382107 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@382108 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 8dd00ce0f7dc5def8992a197db33f066410d8f52..ab3704ada0d3796e1643cec607d3b864fc704b64 100644 (file)
@@ -17146,7 +17146,16 @@ static int get_rpid(struct sip_pvt *p, struct sip_request *oreq)
                return get_pai(p, req);
        }
 
+       /*
+        * RPID is not:
+        *   rpid = (name-addr / addr-spec) *(SEMI rpi-token)
+        * But it is:
+        *   rpid = [display-name] LAQUOT addr-spec RAQUOT *(SEMI rpi-token)
+        * Ergo, calling parse_name_andor_addr() on it wouldn't be
+        * correct because that would allow addr-spec style too.
+        */
        start = tmp;
+       /* Quoted (note that we're not dealing with escapes properly) */
        if (*start == '"') {
                *start++ = '\0';
                end = strchr(start, '"');
@@ -17155,6 +17164,17 @@ static int get_rpid(struct sip_pvt *p, struct sip_request *oreq)
                *end++ = '\0';
                cid_name = start;
                start = ast_skip_blanks(end);
+       /* Unquoted */
+       } else {
+               cid_name = start;
+               start = end = strchr(start, '<');
+               if (!start) {
+                       return 0;
+               }
+               /* trim blanks if there are any. the mandatory NUL is done below */
+               while (--end >= cid_name && *end < 33) {
+                       *end = '\0';
+               }
        }
 
        if (*start != '<')