[Asterisk-cvs] asterisk/channels chan_sip.c,1.211,1.212

markster at lists.digium.com markster at lists.digium.com
Wed Nov 12 18:16:48 CST 2003


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

Modified Files:
	chan_sip.c 
Log Message:
Properly decode strings in REPLACES and ignore leading whitespace


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.211
retrieving revision 1.212
diff -u -d -r1.211 -r1.212
--- chan_sip.c	12 Nov 2003 16:36:35 -0000	1.211
+++ chan_sip.c	13 Nov 2003 00:43:02 -0000	1.212
@@ -3684,6 +3684,18 @@
 	return -1;
 }
 
+static int hex2int(char a)
+{
+	if ((a >= '0') && (a <= '9')) {
+		return a - '0';
+	} else if ((a >= 'a') && (a <= 'f')) {
+		return a - 'a' + 10;
+	} else if ((a >= 'A') && (a <= 'F')) {
+		return a - 'A' + 10;
+	}
+	return 0;
+}
+
 static int get_refer_info(struct sip_pvt *p, struct sip_request *oreq)
 {
 	char tmp[256] = "", *c, *a;
@@ -3722,13 +3734,17 @@
 			if ((a = strchr(tmp5, '%'))) {
 				/* Yuck!  Pingtel converts the '@' to a %40, icky icky!  Convert
 				   back to an '@' */
-				if ((a[1] == '4') && (a[2] == '0')) {
-					*a = '@';
-					memmove(a + 1, a+3, strlen(a + 3));
-				}
+				*a = hex2int(a[1]) * 16 + hex2int(a[2]);
+				memmove(a + 1, a+3, strlen(a + 3) + 1);
 			}
 			if ((a = strchr(tmp5, '%'))) 
 				*a = '\0';
+			if ((a = strchr(tmp5, ';'))) 
+				*a = '\0';
+			/* Skip leading whitespace */
+			while(tmp[0] && (tmp[0] < 33))
+				memmove(tmp, tmp+1, strlen(tmp));
+				
 		}
 	}
 	




More information about the svn-commits mailing list