[asterisk-commits] tilghman: trunk r288160 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 21 17:58:15 CDT 2010


Author: tilghman
Date: Tue Sep 21 17:58:10 2010
New Revision: 288160

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=288160
Log:
Merged revisions 288159 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r288159 | tilghman | 2010-09-21 17:57:22 -0500 (Tue, 21 Sep 2010) | 29 lines
  
  Merged revisions 288113 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r288113 | tilghman | 2010-09-21 16:59:46 -0500 (Tue, 21 Sep 2010) | 22 lines
    
    Merged revisions 288112 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r288112 | tilghman | 2010-09-21 16:58:13 -0500 (Tue, 21 Sep 2010) | 15 lines
      
      Try both the encoded and unencoded subscription URI for a match in hints.
      
      When a phone sends an encoded URI for a subscription, the URI is not matched
      with the actual hint that is in decoded format.  For example, if we have an
      extension with a hint that is named: "#5601" or "*5601", the subscription will
      work fine if the phone subscribes with an already decoded URI, but when it's
      decoded like "%255601" or "%2A5601", Asterisk is unable to match it with the
      correct hint.
      
      (closes issue #17785)
       Reported by: ramonpeek
       Patches: 
             20100831__issue17785.diff.txt uploaded by tilghman (license 14)
       Tested by: ramonpeek
    ........
  ................
................

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

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

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=288160&r1=288159&r2=288160
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Sep 21 17:58:10 2010
@@ -14364,26 +14364,35 @@
 		ast_verbose("Looking for %s in %s (domain %s)\n", uri, p->context, p->domain);
 	}
 
+	/* Since extensions.conf can have unescaped characters, try matching a
+	 * decoded uri in addition to the non-decoded uri. */
+	decoded_uri = ast_strdupa(uri);
+	ast_uri_decode(decoded_uri);
+
 	/* If this is a subscription we actually just need to see if a hint exists for the extension */
 	if (req->method == SIP_SUBSCRIBE) {
 		char hint[AST_MAX_EXTENSION];
-		return (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, p->exten) ?
-			SIP_GET_DEST_EXTEN_FOUND :
-			SIP_GET_DEST_EXTEN_NOT_FOUND);
+		int which = 0;
+		if (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, uri) ||
+		    (ast_get_hint(hint, sizeof(hint), NULL, 0, NULL, p->context, decoded_uri) && (which = 1))) {
+			if (!oreq) {
+				ast_string_field_set(p, exten, which ? decoded_uri : uri);
+			}
+			return SIP_GET_DEST_EXTEN_FOUND;
+		} else {
+			return SIP_GET_DEST_EXTEN_NOT_FOUND;
+		}
 	} else {
 		struct ast_cc_agent *agent;
-		decoded_uri = ast_strdupa(uri);
-		ast_uri_decode(decoded_uri);
+		int which = 0;
 		/* 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)) ||
-			ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) ||
+		    (ast_exists_extension(NULL, p->context, decoded_uri, 1, S_OR(p->cid_num, from)) && (which = 1)) ||
 		    !strcmp(decoded_uri, ast_pickup_ext())) {
 			if (!oreq) {
-				ast_string_field_set(p, exten, decoded_uri);
+				ast_string_field_set(p, exten, which ? decoded_uri : uri);
 			}
 			return SIP_GET_DEST_EXTEN_FOUND;
 		} else if ((agent = find_sip_cc_agent_by_notify_uri(tmp))) {




More information about the asterisk-commits mailing list