diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 1b965b4a76..466bc22541 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -514,7 +514,7 @@ SWITCH_DECLARE(char *) switch_separate_paren_args(char *str); SWITCH_DECLARE(const char *) switch_stristr(const char *instr, const char *str); SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip); SWITCH_DECLARE(char *) switch_replace_char(char *str, char from, char to, switch_bool_t dup); -SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len); +SWITCH_DECLARE(switch_bool_t) switch_ast2regex(const char *pat, char *rbuf, size_t len); /*! \brief Escape a string by prefixing a list of characters with an escape character diff --git a/src/switch_regex.c b/src/switch_regex.c index 697ba1cf62..aee8f2b9e3 100644 --- a/src/switch_regex.c +++ b/src/switch_regex.c @@ -60,11 +60,18 @@ SWITCH_DECLARE(int) switch_regex_perform(const char *field, const char *expressi int match_count = 0; char *tmp = NULL; uint32_t flags = 0; + char abuf[256] = ""; if (!(field && expression)) { return 0; } + if (*expression == '_') { + if (switch_ast2regex(expression + 1, abuf, sizeof(abuf))) { + expression = abuf; + } + } + if (*expression == '/') { char *opts = NULL; tmp = strdup(expression + 1); diff --git a/src/switch_utils.c b/src/switch_utils.c index 8b3088f03f..5829140098 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -565,9 +565,9 @@ SWITCH_DECLARE(switch_bool_t) switch_is_lan_addr(const char *ip) )? SWITCH_FALSE : SWITCH_TRUE; } -SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len) +SWITCH_DECLARE(switch_bool_t) switch_ast2regex(const char *pat, char *rbuf, size_t len) { - char *p = pat; + const char *p = pat; if (!pat) { return SWITCH_FALSE;