diff -Naur asterisk/ast_expr.y asterisk_regexp_patch/ast_expr.y --- asterisk/ast_expr.y 2004-05-03 20:23:35.000000000 -0700 +++ asterisk_regexp_patch/ast_expr.y 2004-06-07 20:11:00.000000000 -0700 @@ -175,6 +175,7 @@ struct val *vp; size_t i; int isint; + char* p; vp = (struct val *) malloc (sizeof (*vp)); if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { @@ -182,12 +183,26 @@ return(NULL); } + i = 0; + for( p=s; *p; p++ ) { + if( *p=='\\' ) { + p++; + if( *p==0 ) { + /* Slash before the end of the string */ + vp->u.s[i++] = '\\'; + break; + } + } + vp->u.s[i++] = *p; + } + vp->u.s[i++] = 0; + for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; isint && i < strlen(s); i++) { if(!isdigit(s[i])) - isint = 0; + isint = 0; } if (isint) @@ -304,8 +319,15 @@ { /* opening quote. find the closing quote */ char *t2=t1+1; - while( *t2 && *t2 != '"') - t2++; + while( *t2 && *t2 != '"') { + /* Watch for escape slashes */ + if( *t2=='\\' ) { + t2++; + if( !*t2 ) + break; + } + t2++; + } if( *t2 == '"' ) { if( *(t2+1) == ' ' || *(t2+1) == 0 ) @@ -826,7 +848,7 @@ to_string(b); /* compile regular expression */ - if ((eval = regcomp (&rp, b->u.s, 0)) != 0) { + if ((eval = regcomp (&rp, b->u.s, REG_EXTENDED)) != 0) { regerror (eval, &rp, errbuf, sizeof(errbuf)); ast_log(LOG_WARNING,"regcomp() error : %s",errbuf); free_value(a); diff -Naur asterisk/pbx.c asterisk_regexp_patch/pbx.c --- asterisk/pbx.c 2004-05-26 12:24:47.000000000 -0700 +++ asterisk_regexp_patch/pbx.c 2004-06-07 20:10:51.000000000 -0700 @@ -795,6 +795,18 @@ /* length is zero */ *ret = "0"; } + } else if (!strncasecmp(var,"ESCAPEQUOTES(",7)) { + int escapequotes_len = 13; + char* p; + int n = 0; + /* Scan until the end of string or ) */ + for( p=var+escapequotes_len; *p && (*p!=')'); p++ ) { + if( *p=='"' ) { + workspace[n++] = '\\'; + } + workspace[n++] = *p; + } + *ret = workspace; } else if ((first=strchr(var,':'))) { strncpy(tmpvar, var, sizeof(tmpvar) - 1); first = strchr(tmpvar, ':');