From e274938dc9a1bd0a9b4d7fcb3d9f3a81dc8ae37e Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Thu, 15 May 2008 10:07:36 +0000 Subject: More ticket #533: fixed bug in Retry-After parser (thanks Samuel Vinson) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1957 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip/sip_parser.c | 5 ++++- pjsip/src/test-pjsip/msg_test.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'pjsip/src') diff --git a/pjsip/src/pjsip/sip_parser.c b/pjsip/src/pjsip/sip_parser.c index 839e3bed..273d9993 100644 --- a/pjsip/src/pjsip/sip_parser.c +++ b/pjsip/src/pjsip/sip_parser.c @@ -1834,10 +1834,13 @@ static pjsip_hdr* parse_hdr_retry_after(pjsip_parse_ctx *ctx) hdr->ivalue = pj_strtoul(&tmp); while (!pj_scan_is_eof(scanner) && *scanner->curptr!='\r' && - *scanner->curptr=='\n') + *scanner->curptr!='\n') { if (*scanner->curptr=='(') { pj_scan_get_quote(scanner, '(', ')', &hdr->comment); + /* Trim the leading and ending parens */ + hdr->comment.ptr++; + hdr->comment.slen -= 2; } else if (*scanner->curptr==';') { pjsip_param *prm = PJ_POOL_ALLOC_T(ctx->pool, pjsip_param); int_parse_param(scanner, ctx->pool, &prm->name, &prm->value, 0); diff --git a/pjsip/src/test-pjsip/msg_test.c b/pjsip/src/test-pjsip/msg_test.c index c271aab8..a1bee18f 100644 --- a/pjsip/src/test-pjsip/msg_test.c +++ b/pjsip/src/test-pjsip/msg_test.c @@ -800,6 +800,7 @@ static int hdr_test_via(pjsip_hdr *h); static int hdr_test_via_ipv6_1(pjsip_hdr *h); static int hdr_test_via_ipv6_2(pjsip_hdr *h); static int hdr_test_via_ipv6_3(pjsip_hdr *h); +static int hdr_test_retry_after1(pjsip_hdr *h); #define GENERIC_PARAM "p0=a;p1=\"ab:;cd\";p2=ab%3acd;p3" @@ -972,6 +973,13 @@ struct hdr_test_t "Via", "v", "SIP/2.0/UDP [::1];rport=5061;received=::2", &hdr_test_via_ipv6_3 + }, + + { + /* Retry-After header with comment */ + "Retry-After", NULL, + "10(Already Pending Register)", + &hdr_test_retry_after1 } }; @@ -1526,6 +1534,23 @@ static int hdr_test_via_ipv6_3(pjsip_hdr *h) return 0; } +/* "10(Already Pending Register)" */ +static int hdr_test_retry_after1(pjsip_hdr *h) +{ + pjsip_retry_after_hdr *hdr = (pjsip_retry_after_hdr*)h; + + if (h->type != PJSIP_H_RETRY_AFTER) + return -2910; + + if (hdr->ivalue != 10) + return -2920; + + if (pj_strcmp2(&hdr->comment, "Already Pending Register")) + return -2930; + + return 0; +} + static int hdr_test(void) { unsigned i; -- cgit v1.2.3