]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add backslash escape char in channel variable expansion
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 21 Apr 2007 14:17:43 +0000 (14:17 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 21 Apr 2007 14:17:43 +0000 (14:17 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4995 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_channel.c

index df82295b94a9783ca494c0a0bdcc3897b80f56c6..8100f9d0fc9fbca24c88892921559b186fcbeb1a 100644 (file)
@@ -1225,6 +1225,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
        char *data, *indup;
        size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128;
        char *sub_val = NULL, *func_val = NULL;
+       int nv = 0;
 
        if (!in || !strchr(in, '$')) {
                return in;
@@ -1239,13 +1240,27 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
                for (p = indup; *p; p++) {
                        vtype = 0;
 
-                       if (*p == '$') {
+                       if (*p == '\\') {
+                               if (*(p + 1) == '$') {
+                                       nv = 1;
+                               }
+                               p++;
+                       }
+
+                       if (*p == '$' && !nv) {
                                vtype = 1;
                                if (*(p + 1) != '{') {
                                        vtype = 2;
                                }
                        }
 
+                       if (nv) {
+                               *c++ = *p;
+                               len++;
+                               nv = 0;
+                               continue;
+                       }
+
                        if (vtype) {
                                char *s = p, *e, *vname, *vval = NULL;
                                size_t nlen;