[Asterisk-cvs] asterisk/channels chan_sip.c,1.497,1.498

markster at lists.digium.com markster at lists.digium.com
Thu Sep 9 22:01:01 CDT 2004


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv10288/channels

Modified Files:
	chan_sip.c 
Log Message:
Handle both pre- and post- whitespace if pedantic checking is on (bug #2411)


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.497
retrieving revision 1.498
diff -u -d -r1.497 -r1.498
--- chan_sip.c	9 Sep 2004 15:40:07 -0000	1.497
+++ chan_sip.c	10 Sep 2004 02:03:05 -0000	1.498
@@ -2165,14 +2165,38 @@
 	int x;
 	int len = strlen(name);
 	char *r;
-	for (x=*start;x<req->headers;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;x<req->headers;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;x<req->headers;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 */




More information about the svn-commits mailing list