[Asterisk-code-review] res_agi: Evaluate dialplan functions and variables in agi exec if ena... (asterisk[master])
Friendly Automation
asteriskteam at digium.com
Tue May 31 15:52:54 CDT 2022
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/18541 )
Change subject: res_agi: Evaluate dialplan functions and variables in agi exec if enabled
......................................................................
res_agi: Evaluate dialplan functions and variables in agi exec if enabled
Agi commnad exec can now evaluate dialplan functions and
variables if variable AGIEXECFULL is set to yes. this can
be useful when executing Playback or Read from agi.
ASTERISK-30058 #close
Change-Id: I669991f540496e7bddd096fec82b52c083036832
---
A doc/CHANGES-staging/res_agi.txt
M res/res_agi.c
2 files changed, 25 insertions(+), 1 deletion(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Friendly Automation: Approved for Submit
diff --git a/doc/CHANGES-staging/res_agi.txt b/doc/CHANGES-staging/res_agi.txt
new file mode 100644
index 0000000..eb6132d
--- /dev/null
+++ b/doc/CHANGES-staging/res_agi.txt
@@ -0,0 +1,5 @@
+Subject: res_agi
+
+Agi command 'exec' can now be enabled
+to evaluate dialplan functions and variables
+by setting the variable AGIEXECFULL to yes.
\ No newline at end of file
diff --git a/res/res_agi.c b/res/res_agi.c
index 339a15d..56e8e76 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -296,6 +296,9 @@
<replaceable>options</replaceable>.</para>
<para>Returns whatever the <replaceable>application</replaceable> returns, or
<literal>-2</literal> on failure to find <replaceable>application</replaceable>.</para>
+ <note>
+ <para>exec does not evaluate dialplan functions and variables unless it is explicitly enabled by setting the <variable>AGIEXECFULL</variable> variable to <literal>yes</literal>.</para>
+ </note>
</description>
<see-also>
<ref type="application">AGI</ref>
@@ -3121,6 +3124,9 @@
{
int res, workaround;
struct ast_app *app_to_exec;
+ const char *agi_exec_full_str;
+ int agi_exec_full;
+ struct ast_str *data_with_var = NULL;
if (argc < 2)
return RESULT_SHOWUSAGE;
@@ -3132,8 +3138,21 @@
if (!(workaround = ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS))) {
ast_set_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS);
}
+ agi_exec_full_str = pbx_builtin_getvar_helper(chan, "AGIEXECFULL");
+ agi_exec_full = ast_true(agi_exec_full_str);
ast_channel_unlock(chan);
- res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]);
+
+ if (agi_exec_full) {
+ if ((data_with_var = ast_str_create(16))) {
+ ast_str_substitute_variables(&data_with_var, 0, chan, argv[2]);
+ res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : ast_str_buffer(data_with_var));
+ ast_free(data_with_var);
+ } else {
+ res = -2;
+ }
+ } else {
+ res = pbx_exec(chan, app_to_exec, argc == 2 ? "" : argv[2]);
+ }
if (!workaround) {
ast_channel_clear_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18541
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: I669991f540496e7bddd096fec82b52c083036832
Gerrit-Change-Number: 18541
Gerrit-PatchSet: 5
Gerrit-Owner: Shloime Rosenblum <shloimerosenblum at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220531/dfaf5f6a/attachment.html>
More information about the asterisk-code-review
mailing list