aboutsummaryrefslogtreecommitdiffstats
path: root/main/pbx.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-12-17 17:17:51 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-12-17 17:17:51 +0000
commitac8ede4567c43ae87a6c51b42babe5463b39b19c (patch)
treef5378b91dc75dc804fc218f9c6f6f7fe90fab76e /main/pbx.c
parent9a832861059f99325d4fbb7230282dc1b8df41df (diff)
Use context from which Macro is executed, not macro context, if applicable.
Also, ensure that the extension COULD match, not just that it won't match more. (closes issue #16113) Reported by: OrNix Patches: 20091216__issue16113.diff.txt uploaded by tilghman (license 14) Tested by: OrNix git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@235421 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/pbx.c')
-rw-r--r--main/pbx.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/main/pbx.c b/main/pbx.c
index 85a3e3efe..87e608e87 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -5711,8 +5711,16 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
if (ast_strlen_zero(args.lang))
args.lang = (char *)chan->language; /* XXX this is const */
- if (ast_strlen_zero(args.context))
- args.context = chan->context;
+ if (ast_strlen_zero(args.context)) {
+ const char *context;
+ ast_channel_lock(chan);
+ if ((context = pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT"))) {
+ args.context = ast_strdupa(context);
+ } else {
+ args.context = chan->context;
+ }
+ ast_channel_unlock(chan);
+ }
if (args.options) {
if (!strcasecmp(args.options, "skip"))
@@ -5768,7 +5776,9 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
* gone immediately to the "i" extension, but will now need to wait for a
* timeout.
*/
- if ((exten[0] = res) && !ast_matchmore_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
+ if ((exten[0] = res) &&
+ ast_canmatch_extension(chan, args.context, exten, 1, chan->cid.cid_num) &&
+ !ast_matchmore_extension(chan, args.context, exten, 1, chan->cid.cid_num)) {
snprintf(chan->exten, sizeof(chan->exten), "%c", res);
ast_copy_string(chan->context, args.context, sizeof(chan->context));
chan->priority = 0;