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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 7 16:42:24 CST 2007


Author: mmichelson
Date: Wed Nov  7 16:42:24 2007
New Revision: 89091

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

........
r89090 | mmichelson | 2007-11-07 16:40:35 -0600 (Wed, 07 Nov 2007) | 6 lines

This patch makes it possible for SIP phones to dial extensions defined with '#' characters
in extensions.conf AND maintain their escaped characters when forming URI's

(closes issue #10681, reported by cahen, patched by me, code review by file)


........

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=89091&r1=89090&r2=89091
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Nov  7 16:42:24 2007
@@ -4502,6 +4502,16 @@
 	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
@@ -4637,8 +4647,7 @@
 	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, i->exten, sizeof(tmp->exten));
-
+	ast_copy_string(tmp->exten, translate_escaped_pound(ast_strdupa(i->exten)), sizeof(tmp->exten));
 
 	/* Don't use ast_set_callerid() here because it will
 	 * generate an unnecessary NewCallerID event  */
@@ -9585,6 +9594,19 @@
 			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;
+			}
 		}
 	}
 




More information about the svn-commits mailing list