[svn-commits] rmudgett: branch 12 r402416 - in /branches/12: ./ apps/confbridge/ configs/ m...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Nov 1 20:11:18 CDT 2013


Author: rmudgett
Date: Fri Nov  1 20:11:16 2013
New Revision: 402416

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402416
Log:
config: Allow ConfBridge DTMF menus to have '#' as the first digit.

ConfBridge allows custom DTMF menus to be created in the confbridge.conf
file by assigning a DTMF key sequence to a sequence of actions as follows:

DTMF-sequence = action,action...

Unfortunately, the normal config file processing code interprets an
initial '#' character as starting a directive such as #include.

* Add the ability to escape the first non-blank character in a config line
so the '#' character can be used without triggering the directive
processing code.

(closes issue AFS-2)
(closes issue ASTERISK-22478)
Reported by: Nicolas Tanski
Patches:
      jira_asterisk_22478_v11.patch (license #5621) patch uploaded by rmudgett (modified)

Review: https://reviewboard.asterisk.org/r/2969/
........

Merged revisions 402407 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    branches/12/   (props changed)
    branches/12/apps/confbridge/conf_config_parser.c
    branches/12/configs/confbridge.conf.sample
    branches/12/main/config.c

Propchange: branches/12/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: branches/12/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/confbridge/conf_config_parser.c?view=diff&rev=402416&r1=402415&r2=402416
==============================================================================
--- branches/12/apps/confbridge/conf_config_parser.c (original)
+++ branches/12/apps/confbridge/conf_config_parser.c Fri Nov  1 20:11:16 2013
@@ -427,6 +427,13 @@
 					is passed in to ConfBridge as an argument in the dialplan.</para>
 					<para>Below is a list of menu actions that can be assigned to a DTMF sequence.</para>
 					<note><para>
+						To have the first DTMF digit in a sequence be the '#' character, you need to
+						escape it.  If it is not escaped then normal config file processing will
+						think it is a directive like #include.  For example: The mute setting is
+						toggled when <literal>#1</literal> is pressed.</para>
+						<para><literal>\#1=toggle_mute</literal></para>
+					</note>
+					<note><para>
 					A single DTMF sequence can have multiple actions associated with it. This is
 					accomplished by stringing the actions together and using a <literal>,</literal> as the
 					delimiter.  Example:  Both listening and talking volume is reset when <literal>5</literal> is
@@ -450,7 +457,7 @@
 						<enum name="toggle_mute"><para>
 							Toggle turning on and off mute.  Mute will make the user silent
 							to everyone else, but the user will still be able to listen in.
-							continue to collect the dtmf sequence.</para></enum>
+							</para></enum>
 						<enum name="no_op"><para>
 							This action does nothing (No Operation). Its only real purpose exists for
 							being able to reserve a sequence in the config as a menu exit sequence.</para></enum>

Modified: branches/12/configs/confbridge.conf.sample
URL: http://svnview.digium.com/svn/asterisk/branches/12/configs/confbridge.conf.sample?view=diff&rev=402416&r1=402415&r2=402416
==============================================================================
--- branches/12/configs/confbridge.conf.sample (original)
+++ branches/12/configs/confbridge.conf.sample Fri Nov  1 20:11:16 2013
@@ -62,7 +62,7 @@
                             ;    loose the user will hear themselves briefly each
                             ;    time they begin talking until the dsp has time to
                             ;    establish that they are in fact talking.
-                            ; 2. When talk detection AMI events are enabled, this value 
+                            ; 2. When talk detection AMI events are enabled, this value
                             ;    determines when talking has begun which results in
                             ;    an AMI event to fire.  If this value is set too tight
                             ;    AMI events may be falsely triggered by variants in
@@ -248,6 +248,11 @@
 ; Below is a list of menu actions that can be assigned
 ; to a DTMF sequence.
 ;
+; To have the first DTMF digit in a sequence be the '#' character, you need to
+; escape it.  If it is not escaped then normal config file processing will
+; think it is a directive like #include.  For example:
+; \#1=toggle_mute                      ; Pressing #1 will toggle the mute setting.
+;
 ; A single DTMF sequence can have multiple actions associated with it. This is
 ; accomplished by stringing the actions together and using a ',' as the delimiter.
 ; Example:  Both listening and talking volume is reset when '5' is pressed.
@@ -270,7 +275,7 @@
                                        ; using the '&' character as a delimiter.
 ; toggle_mute      ; Toggle turning on and off mute.  Mute will make the user silent
                    ; to everyone else, but the user will still be able to listen in.
-                   ; continue to collect the dtmf sequence.
+
 ; no_op ; This action does nothing (No Operation). Its only real purpose exists for
         ; being able to reserve a sequence in the config as a menu exit sequence.
 ; decrease_listening_volume ; Decreases the channel's listening volume.

Modified: branches/12/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/config.c?view=diff&rev=402416&r1=402415&r2=402416
==============================================================================
--- branches/12/main/config.c (original)
+++ branches/12/main/config.c Fri Nov  1 20:11:16 2013
@@ -1419,14 +1419,26 @@
 	} else {
 		/* Just a line (variable = value) */
 		int object = 0;
+		int is_escaped;
+
 		if (!(*cat)) {
 			ast_log(LOG_WARNING,
 				"parse error: No category context for line %d of %s\n", lineno, configfile);
 			return -1;
 		}
-		c = strchr(cur, '=');
-
-		if (c && c > cur && (*(c - 1) == '+')) {
+
+		is_escaped = cur[0] == '\\';
+		if (is_escaped) {
+			/* First character is escaped. */
+			++cur;
+			if (cur[0] < 33) {
+				ast_log(LOG_ERROR, "Invalid escape in line %d of %s\n", lineno, configfile);
+				return -1;
+			}
+		}
+		c = strchr(cur + is_escaped, '=');
+
+		if (c && c > cur + is_escaped && (*(c - 1) == '+')) {
 			struct ast_variable *var, *replace = NULL;
 			struct ast_str **str = ast_threadstorage_get(&appendbuf, sizeof(*str));
 
@@ -1462,8 +1474,11 @@
 				object = 1;
 				c++;
 			}
+			cur = ast_strip(cur);
 set_new_variable:
-			if ((v = ast_variable_new(ast_strip(cur), ast_strip(c), S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile)))) {
+			if (ast_strlen_zero(cur)) {
+				ast_log(LOG_WARNING, "No variable name in line %d of %s\n", lineno, configfile);
+			} else if ((v = ast_variable_new(cur, ast_strip(c), S_OR(suggested_include_file, cfg->include_level == 1 ? "" : configfile)))) {
 				v->lineno = lineno;
 				v->object = object;
 				*last_cat = 0;




More information about the svn-commits mailing list