FS-5131 --resolve indeed, nice catch

This commit is contained in:
Anthony Minessale 2013-02-28 09:28:00 -06:00
parent 1b8ef1842e
commit bf93eb47e9
2 changed files with 33 additions and 12 deletions

View File

@ -919,11 +919,19 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
static inline switch_bool_t switch_is_file_path(const char *file)
{
const char *e;
int r;
int r, x;
if (*file == '[' && *(file + 1) == *SWITCH_PATH_SEPARATOR) {
if ((e = switch_find_end_paren(file, '[', ']'))) {
file = e + 1;
for (x = 0; x < 2; x++) {
if (*file == '[' && *(file + 1) == *SWITCH_PATH_SEPARATOR) {
if ((e = switch_find_end_paren(file, '[', ']'))) {
file = e + 1;
}
} else if (*file == '{') {
if ((e = switch_find_end_paren(file, '{', '}'))) {
file = e + 1;
}
} else {
break;
}
}
#ifdef WIN32

View File

@ -1185,20 +1185,33 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
if (!strstr(file, SWITCH_URL_SEPARATOR)) {
if (!switch_is_file_path(file)) {
char *tfile = NULL;
char *tfile = NULL, *tfile2 = NULL;
char *e;
int x;
if (*file == '[') {
tfile = switch_core_session_strdup(session, file);
if ((e = switch_find_end_paren(tfile, '[', ']'))) {
*e = '\0';
file = e + 1;
for (x = 0; x < 2; x++) {
if (*file == '[') {
tfile = switch_core_session_strdup(session, file);
if ((e = switch_find_end_paren(tfile, '[', ']'))) {
*e = '\0';
file = e + 1;
} else {
tfile = NULL;
}
} else if (*file == '{') {
tfile2 = switch_core_session_strdup(session, file);
if ((e = switch_find_end_paren(tfile2, '{', '}'))) {
*e = '\0';
file = e + 1;
} else {
tfile2 = NULL;
}
} else {
tfile = NULL;
break;
}
}
file = switch_core_session_sprintf(session, "%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", prefix, SWITCH_PATH_SEPARATOR, file);
file = switch_core_session_sprintf(session, "%s%s%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", switch_str_nil(tfile2), tfile2 ? "}" : "", prefix, SWITCH_PATH_SEPARATOR, file);
}
if ((ext = strrchr(file, '.'))) {
ext++;