Index: pbx/pbx_config.c =================================================================== --- pbx/pbx_config.c (revision 230109) +++ pbx/pbx_config.c (working copy) @@ -953,7 +953,29 @@ } } app = whole_exten; - if (app && (start = strchr(app, '(')) && (end = strrchr(app, ')'))) { + if (iprior == PRIORITY_HINT) { + int brace = 0, square = 0; + char *next = app; + app_data = NULL; + /* Carefully find the next comma that isn't within an expression */ + for (next = app; !ast_strlen_zero(next); next++) { + if (next[0] == '$' && next[1] == '{') { + brace++; + next++; + } else if (next[0] == '$' && next[1] == '[') { + square++; + next++; + } else if (next[0] == '}' && brace > 0) { + brace--; + } else if (next[0] == ']' && square > 0) { + square--; + } else if (next[0] == ',' && (brace + square) == 0) { + next[0] = '\0'; + app_data = &next[1]; + break; + } + } + } else if (app && (start = strchr(app, '(')) && (end = strrchr(app, ')'))) { *start = *end = '\0'; app_data = start + 1; } else { @@ -963,8 +985,9 @@ *app_data = '\0'; app_data++; } - } else + } else { app_data = NULL; + } } if (!exten || !prior || !app || (!app_data && iprior != PRIORITY_HINT)) @@ -1491,8 +1514,30 @@ ipri = 0; } appl = S_OR(stringp, ""); + if (ipri == PRIORITY_HINT) { + int brace = 0, square = 0; + char *next = appl; + data = NULL; + /* Carefully find the next comma that isn't within an expression */ + for (next = app; !ast_strlen_zero(next); next++) { + if (next[0] == '$' && next[1] == '{') { + brace++; + next++; + } else if (next[0] == '$' && next[1] == '[') { + square++; + next++; + } else if (next[0] == '}' && brace > 0) { + brace--; + } else if (next[0] == ']' && square > 0) { + square--; + } else if (next[0] == ',' && (brace + square) == 0) { + next[0] = '\0'; + data = &next[1]; + break; + } + } /* Find the first occurrence of '(' */ - if (!(firstp = strchr(appl, '('))) { + } else if (!(firstp = strchr(appl, '('))) { /* No arguments */ data = ""; } else {