[Asterisk-cvs] asterisk/channels chan_sip.c,1.426,1.427

markster at lists.digium.com markster at lists.digium.com
Fri Jun 25 14:37:13 CDT 2004


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

Modified Files:
	chan_sip.c 
Log Message:
Handle URL encoded stuff in pedantic checking


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.426
retrieving revision 1.427
diff -u -d -r1.426 -r1.427
--- chan_sip.c	25 Jun 2004 05:52:54 -0000	1.426
+++ chan_sip.c	25 Jun 2004 18:23:06 -0000	1.427
@@ -866,6 +866,30 @@
 	return res;
 }
 
+static void url_decode(char *s) 
+{
+	char *o = s;
+	unsigned int tmp;
+	while(*s) {
+		switch(*s) {
+		case '%':
+			if (strlen(s) > 2) {
+				if (sscanf(s + 1, "%2x", &tmp) == 1) {
+					*o = tmp;
+					s += 2;	/* Will be incremented once more when we break out */
+					break;
+				}
+			}
+			/* Fall through if something wasn't right with the formatting */
+		default:
+			*o = *s;
+		}
+		s++;
+		o++;
+	}
+	*o = '\0';
+}
+
 /*--- ditch_braces: Pick out text in braces from character string  ---*/
 static char *ditch_braces(char *tmp)
 {
@@ -1600,8 +1624,8 @@
 	switch(cause) {
 		case 404:       /* Not found */
 			return AST_CAUSE_UNALLOCATED;
-                case 483:       /* Too many hops */
-                        return AST_CAUSE_FAILURE;
+		case 483:       /* Too many hops */
+			return AST_CAUSE_FAILURE;
 		case 486:
 			return AST_CAUSE_BUSY;
 		default:
@@ -4656,6 +4680,8 @@
 		} else
 			strncpy(p->fromdomain, fr, sizeof(p->fromdomain) - 1);
 	}
+	if (pedanticsipchecking)
+		url_decode(c);
 	if (sip_debug_test_pvt(p))
 		ast_verbose("Looking for %s in %s\n", c, p->context);
 	if (ast_exists_extension(NULL, p->context, c, 1, fr) ||




More information about the svn-commits mailing list