[svn-commits] mmichelson: trunk r89120 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 8 15:01:02 CST 2007


Author: mmichelson
Date: Thu Nov  8 15:01:02 2007
New Revision: 89120

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89120
Log:
Merged revisions 89119 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r89119 | mmichelson | 2007-11-08 15:00:08 -0600 (Thu, 08 Nov 2007) | 7 lines

Rework of the commit I made yesterday to use the already built-in
ast_uri_decode function as opposed to my home-rolled one. Also added
comments.

Thanks to oej for pointing me in the right direction


........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=89120&r1=89119&r2=89120
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Nov  8 15:01:02 2007
@@ -4503,17 +4503,6 @@
 	return res;
 }
 
-static char *translate_escaped_pound(char *exten)
-{
-	char *rest, *marker;
-	while((marker = strstr(exten, "%23"))) {
-		rest = marker + 3;
-		*marker++ = '#';
-		memmove(marker, rest, strlen(rest) + 1);
-	}
-	return exten;
-}
-
 
 /*! \brief Initiate a call in the SIP channel
 	called from sip_request_call (calls from the pbx ) for outbound channels
@@ -4531,6 +4520,7 @@
 	int needvideo = 0;
 	int needtext = 0;
 	char buf[BUFSIZ];
+	char *decoded_exten;
 	{
 		const char *my_name;	/* pick a good name */
 	
@@ -4648,7 +4638,13 @@
 	i->owner = tmp;
 	ast_module_ref(ast_module_info->self);
 	ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
-	ast_copy_string(tmp->exten, translate_escaped_pound(ast_strdupa(i->exten)), sizeof(tmp->exten));
+	/*Since it is valid to have extensions in the dialplan that have unescaped characters in them
+	 * we should decode the uri before storing it in the channel, but leave it encoded in the sip_pvt
+	 * structure so that there aren't issues when forming URI's
+	 */
+	decoded_exten = ast_strdupa(i->exten);
+	ast_uri_decode(decoded_exten);
+	ast_copy_string(tmp->exten, decoded_exten, sizeof(tmp->exten));
 
 	/* Don't use ast_set_callerid() here because it will
 	 * generate an unnecessary NewCallerID event  */
@@ -9600,26 +9596,17 @@
 	} else {
 		/* Check the dialplan for the username part of the request URI,
 		   the domain will be stored in the SIPDOMAIN variable
+		   Since extensions.conf can have unescaped characters, try matching a decoded
+		   uri in addition to the non-decoded uri
 		   Return 0 if we have a matching extension */
-		if (ast_exists_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from)) ||
+		char *decoded_uri = ast_strdupa(uri);
+		ast_uri_decode(decoded_uri);
+		if (ast_exists_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from)) || ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) ||
 		    !strcmp(uri, ast_pickup_ext())) {
 			if (!oreq)
 				ast_string_field_set(p, exten, uri);
 			return 0;
-		} else { /*Could be trying to match a literal '#'. Try replacing and see if that works.*/
-			char *tmpuri = ast_strdupa(uri);
-			char *rest, *marker;
-			while((marker = strstr(tmpuri, "%23"))) {
-				rest = marker + 3;
-				*marker++ = '#';
-				memmove(marker, rest, strlen(rest) + 1);
-			}
-			if(ast_exists_extension(NULL, p->context, tmpuri, 1, from) || !strcmp(uri, ast_pickup_ext())) {
-				if(!oreq)
-					ast_string_field_set(p, exten, uri);
-				return 0;
-			}
-		}
+		} 
 	}
 
 	/* Return 1 for pickup extension or overlap dialling support (if we support it) */




More information about the svn-commits mailing list