[svn-commits] oej: branch 1.4 r126899 - /branches/1.4/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jul 1 09:27:33 CDT 2008


Author: oej
Date: Tue Jul  1 09:27:33 2008
New Revision: 126899

URL: http://svn.digium.com/view/asterisk?view=rev&rev=126899
Log:
Handle escaped URI's in call pickups. Patch by oej and IgorG.

Reported by: IgorG
Patches: 
      bug12299-11062-v2.patch uploaded by IgorG (license 20)
Tested by: IgorG, oej
(closes issue #12299)

Modified:
    branches/1.4/channels/chan_sip.c

Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=126899&r1=126898&r2=126899
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Tue Jul  1 09:27:33 2008
@@ -8879,6 +8879,7 @@
 	char tmpf[256] = "", *from;
 	struct sip_request *req;
 	char *colon;
+	char *decoded_uri;
 	
 	req = oreq;
 	if (!req)
@@ -8970,25 +8971,25 @@
 		char hint[AST_MAX_EXTENSION];
 		return (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, p->exten) ? 0 : -1);
 	} else {
+		decoded_uri = ast_strdupa(uri);
+		ast_uri_decode(decoded_uri);
 		/* 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 */
-		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())) {
+		    !strcmp(decoded_uri, ast_pickup_ext())) {
 			if (!oreq)
-				ast_string_field_set(p, exten, uri);
+				ast_string_field_set(p, exten, decoded_uri);
 			return 0;
 		} 
 	}
 
 	/* Return 1 for pickup extension or overlap dialling support (if we support it) */
 	if((ast_test_flag(&global_flags[1], SIP_PAGE2_ALLOWOVERLAP) && 
- 	    ast_canmatch_extension(NULL, p->context, uri, 1, S_OR(p->cid_num, from))) ||
-	    !strncmp(uri, ast_pickup_ext(), strlen(uri))) {
+ 	    ast_canmatch_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from))) ||
+	    !strncmp(decoded_uri, ast_pickup_ext(), strlen(decoded_uri))) {
 		return 1;
 	}
 	
@@ -14065,10 +14066,13 @@
 			if (gotdest == 1 && ast_test_flag(&p->flags[1], SIP_PAGE2_ALLOWOVERLAP))
 				transmit_response_reliable(p, "484 Address Incomplete", req);
 			else {
+				char *decoded_exten = ast_strdupa(p->exten);
+				
 				transmit_response_reliable(p, "404 Not Found", req);
+				ast_uri_decode(decoded_exten);
 				ast_log(LOG_NOTICE, "Call from '%s' to extension"
 					" '%s' rejected because extension not found.\n",
-					S_OR(p->username, p->peername), p->exten);
+					S_OR(p->username, p->peername), decoded_exten);
 			}
 			p->invitestate = INV_COMPLETED;	
 			update_call_counter(p, DEC_CALL_LIMIT);




More information about the svn-commits mailing list