From: Mark Spencer Date: Fri, 10 Sep 2004 02:03:05 +0000 (+0000) Subject: Handle both pre- and post- whitespace if pedantic checking is on (bug #2411) X-Git-Tag: 1.0.0~70 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=815318b12f4565f8de6d8e0770fec8d416d6b374;p=thirdparty%2Fasterisk.git Handle both pre- and post- whitespace if pedantic checking is on (bug #2411) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3756 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 0074eee759..c30e6adea5 100755 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2165,14 +2165,38 @@ static char *__get_header(struct sip_request *req, char *name, int *start) int x; int len = strlen(name); char *r; - for (x=*start;xheaders;x++) { - if (!strncasecmp(req->header[x], name, len) && - (req->header[x][len] == ':')) { - r = req->header[x] + len + 1; + if (pedanticsipchecking) { + /* Technically you can place arbitrary whitespace both before and after the ':' in + a header, although RFC3261 clearly says you shouldn't before, and place just + one afterwards. If you shouldn't do it, what absolute idiot decided it was + a good idea to say you can do it, and if you can do it, why in the hell would + you say you shouldn't. */ + for (x=*start;xheaders;x++) { + if (!strncasecmp(req->header[x], name, len)) { + r = req->header[x] + len; + while(*r && (*r < 33)) + r++; + if (*r == ':') { + r++ ; while(*r && (*r < 33)) - r++; + r++; *start = x+1; return r; + } + } + } + } else { + /* We probably shouldn't even bother counting whitespace afterwards but + I guess for backwards compatibility we will */ + for (x=*start;xheaders;x++) { + if (!strncasecmp(req->header[x], name, len) && + (req->header[x][len] == ':')) { + r = req->header[x] + len + 1; + while(*r && (*r < 33)) + r++; + *start = x+1; + return r; + } } } /* Try aliases */