<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19302">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">app_queue.c: Don't escape commas in MONITOR_FILENAME.<br><br>The contents of the MONITOR_FILENAME variable is evaluated when a<br>queue member is connected to a caller, allowing information about the<br>member to be included in the filename.<br><br>This is made possible by using ^{MEMBERINTERFACE} syntax instead of<br>${MEMBERINTERFACE} when assigning a value to MONITOR_FILENAME so that<br>evaluation does not occur immediately. The MONITOR_EXEC variable is<br>handled similarly.<br><br>Because of the way that MONITOR_EXEC works under the hood, the code<br>that performs the variable replacement also escapes commas before<br>doing so. However, this replacement should be taking place after the<br>variable replacement is done so that unescaped commas are not<br>erroneously passed to the MixMonitor start function.<br><br>Finally, having a comma in a filename is not problematic so we now<br>only escape commas after variable replacement is performed on<br>MONITOR_EXEC.<br><br>The main consequence of this change is that you can now use dialplan<br>functions with multiple arguments in MONITOR_FILENAME without the<br>commas being escaped before variable replacement occurs.<br><br>ASTERISK-30236 #close<br><br>Change-Id: Ib18481288c5292e27321e95364d7e63e8917252f<br>---<br>M apps/app_queue.c<br>A doc/CHANGES-staging/app_queue_monitor_filename_commas.txt<br>2 files changed, 58 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/02/19302/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/apps/app_queue.c b/apps/app_queue.c</span><br><span>index 288c0ff..f58667d 100644</span><br><span>--- a/apps/app_queue.c</span><br><span>+++ b/apps/app_queue.c</span><br><span>@@ -6820,8 +6820,13 @@</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+enum escape_type {</span><br><span style="color: hsl(120, 100%, 40%);">+ MONITOR_FILENAME,</span><br><span style="color: hsl(120, 100%, 40%);">+ MONITOR_EXEC,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> static void escape_and_substitute(struct ast_channel *chan, const char *input,</span><br><span style="color: hsl(0, 100%, 40%);">- char *output, size_t size)</span><br><span style="color: hsl(120, 100%, 40%);">+ char *output, size_t size, enum escape_type type)</span><br><span> {</span><br><span> const char *m = input;</span><br><span> char escaped[size];</span><br><span>@@ -6834,9 +6839,6 @@</span><br><span> *p = '$';</span><br><span> }</span><br><span> break;</span><br><span style="color: hsl(0, 100%, 40%);">- case ',':</span><br><span style="color: hsl(0, 100%, 40%);">- *p++ = '\\';</span><br><span style="color: hsl(0, 100%, 40%);">- /* Fall through */</span><br><span> default:</span><br><span> *p = *m;</span><br><span> }</span><br><span>@@ -6849,6 +6851,15 @@</span><br><span> }</span><br><span> </span><br><span> pbx_substitute_variables_helper(chan, escaped, output, size - 1);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (type == MONITOR_EXEC) {</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Commas are only significant to MONITOR_EXEC because of the way that we</span><br><span style="color: hsl(120, 100%, 40%);">+ handle argument passing in ast_mixmonitor_start(). The</span><br><span style="color: hsl(120, 100%, 40%);">+ MONITOR_FILENAME does not have the same limitation so we do not need</span><br><span style="color: hsl(120, 100%, 40%);">+ commas escaped there. */</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_escape(escaped, output, size, ",");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(output, escaped, size);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> static void setup_mixmonitor(struct queue_ent *qe, const char *filename)</span><br><span>@@ -6863,7 +6874,8 @@</span><br><span> escaped_monitor_exec[0] = '\0';</span><br><span> </span><br><span> if (filename) {</span><br><span style="color: hsl(0, 100%, 40%);">- escape_and_substitute(qe->chan, filename, escaped_filename, sizeof(escaped_filename));</span><br><span style="color: hsl(120, 100%, 40%);">+ escape_and_substitute(qe->chan, filename,</span><br><span style="color: hsl(120, 100%, 40%);">+ escaped_filename, sizeof(escaped_filename), MONITOR_FILENAME);</span><br><span> } else {</span><br><span> ast_copy_string(escaped_filename, ast_channel_uniqueid(qe->chan), sizeof(escaped_filename));</span><br><span> }</span><br><span>@@ -6880,7 +6892,8 @@</span><br><span> ast_channel_unlock(qe->chan);</span><br><span> </span><br><span> if (monitor_exec) {</span><br><span style="color: hsl(0, 100%, 40%);">- escape_and_substitute(qe->chan, monitor_exec, escaped_monitor_exec, sizeof(escaped_monitor_exec));</span><br><span style="color: hsl(120, 100%, 40%);">+ escape_and_substitute(qe->chan, monitor_exec,</span><br><span style="color: hsl(120, 100%, 40%);">+ escaped_monitor_exec, sizeof(escaped_monitor_exec), MONITOR_EXEC);</span><br><span> }</span><br><span> </span><br><span> snprintf(file_with_ext, sizeof(file_with_ext), "%s.%s", escaped_filename, qe->parent->monfmt);</span><br><span>diff --git a/doc/CHANGES-staging/app_queue_monitor_filename_commas.txt b/doc/CHANGES-staging/app_queue_monitor_filename_commas.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..f303467</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/app_queue_monitor_filename_commas.txt</span><br><span>@@ -0,0 +1,5 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: app_queue</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Commas in MONITOR_EXEC are now escaped after variable replacement</span><br><span style="color: hsl(120, 100%, 40%);">+occurs instead of before. Additionally, commas are no longer escaped</span><br><span style="color: hsl(120, 100%, 40%);">+at all in MONITOR_FILENAME.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19302">change 19302</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19302"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: Ib18481288c5292e27321e95364d7e63e8917252f </div>
<div style="display:none"> Gerrit-Change-Number: 19302 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>