From 80900446a953da8bc8fc4d0ac3494d9fa90bedca Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 22 Jan 2009 03:42:22 +0000 Subject: [PATCH] beastie git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11352 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_utils.h | 25 +++++++++++++++++++++++++ src/switch_caller.c | 2 +- src/switch_channel.c | 4 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 9cc5418fd1..09707a0e90 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -305,6 +305,31 @@ static inline switch_bool_t switch_string_var_check(char *s, switch_bool_t disab } +static inline switch_bool_t switch_string_var_check_const(const char *s) +{ + const char *p; + int dol = 0; + + for (p = s; p && *p; p++) { + if (*p == '$') { + dol = 1; + } else if (dol) { + if (*p == '{') { + return SWITCH_TRUE; + } else if (*p != '\\') { + dol = 0; + } + } + } + return SWITCH_FALSE; +} + +static inline char *switch_var_clean_string(char *s) +{ + switch_string_var_check(s, SWITCH_TRUE); + return s; +} + static inline char *switch_clean_string(char *s) { char *p; diff --git a/src/switch_caller.c b/src/switch_caller.c index cf8704e173..855f152108 100644 --- a/src/switch_caller.c +++ b/src/switch_caller.c @@ -34,7 +34,7 @@ #include #define profile_dup(a,b,p) if (!switch_strlen_zero(a)) { b = switch_core_strdup(p, a); } else { b = SWITCH_BLANK_STRING; } -#define profile_dup_clean(a,b,p) if (!switch_strlen_zero(a)) { b = switch_clean_string(switch_core_strdup(p, a)); switch_string_var_check( (char *) b , SWITCH_TRUE);} else { b = SWITCH_BLANK_STRING; } +#define profile_dup_clean(a,b,p) if (!switch_strlen_zero(a)) { b = switch_var_clean_string(switch_clean_string(switch_core_strdup(p, a)));} else { b = SWITCH_BLANK_STRING; } SWITCH_DECLARE(switch_caller_profile_t *) switch_caller_profile_new(switch_memory_pool_t *pool, const char *username, diff --git a/src/switch_channel.c b/src/switch_channel.c index e2432ec0b5..cd7800d366 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -584,9 +584,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_cha switch_event_del_header(channel->variables, varname); if (!switch_strlen_zero(value)) { int ok = 1; - + if (var_check) { - ok = !switch_string_var_check((char *)value, SWITCH_FALSE); + ok = !switch_string_var_check_const(value); } if (ok) { switch_event_add_header_string(channel->variables, SWITCH_STACK_BOTTOM, varname, value);