From: Tilghman Lesher Date: Tue, 27 May 2008 13:13:17 +0000 (+0000) Subject: In compat14 mode, don't translate pipes inside expressions, as they aren't X-Git-Tag: 1.6.2.0-beta1~2155 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1c51fec08cd9b55d63c0ba7bf6f641bfdaf33242;p=thirdparty%2Fasterisk.git In compat14 mode, don't translate pipes inside expressions, as they aren't argument delimiters, but rather 'or' symbols. (Closes issue #12723) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@118300 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c index ea2ee9bab8..6e5a9f7e15 100644 --- a/pbx/pbx_realtime.c +++ b/pbx/pbx_realtime.c @@ -181,17 +181,26 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch else if (!strcasecmp(v->name, "appdata")) { if (!compat16) { char *ptr; + int in = 0; tmp = alloca(strlen(v->value) * 2 + 1); for (ptr = tmp; *v->value; v->value++) { if (*v->value == ',') { *ptr++ = '\\'; *ptr++ = ','; - } else if (*v->value == '|') { + } else if (*v->value == '|' && !in) { *ptr++ = ','; } else { *ptr++ = *v->value; } + + /* Don't escape '|', meaning 'or', inside expressions ($[ ]) */ + if (v->value[0] == '[' && v->value[-1] == '$') { + in++; + } else if (v->value[0] == ']' && in) { + in--; + } } + *ptr = '\0'; } else { tmp = ast_strdupa(v->value); }