]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix cache file messup
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 15 Mar 2013 19:20:40 +0000 (14:20 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Sat, 16 Mar 2013 01:34:24 +0000 (20:34 -0500)
src/mod/applications/mod_httapi/mod_httapi.c

index 4b53b87fe5f7a9b223a9bac50ffe69eaf4b7d0f3..fd84b8e86bf28830c2d9d4894be787bcb38daa8b 100644 (file)
@@ -2289,7 +2289,7 @@ SWITCH_STANDARD_APP(httapi_function)
 
 static char *load_cache_data(http_file_context_t *context, const char *url)
 {
-       char *ext = NULL;
+       char *ext = NULL, *dext = NULL, *p;
        char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 };
        char meta_buffer[1024] = "";
        int fd;
@@ -2308,6 +2308,14 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
                        ext = "wav";
                }
        }
+       
+       if (ext && (p = strchr(ext, '?'))) {
+               dext = strdup(ext);
+               if ((p = strchr(dext, '?'))) {
+                       *p = '\0';
+                       ext = dext;
+               } else free(dext);
+       }
 
        context->cache_file_base = switch_core_sprintf(context->pool, "%s%s%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest);
        context->cache_file = switch_core_sprintf(context->pool, "%s%s%s.%s", globals.cache_path, SWITCH_PATH_SEPARATOR, digest, ext);
@@ -2329,6 +2337,8 @@ static char *load_cache_data(http_file_context_t *context, const char *url)
                close(fd);
        }
 
+       switch_safe_free(dext);
+
        return context->cache_file;
 }
 
@@ -2600,6 +2610,12 @@ static switch_status_t locate_url_file(http_file_context_t *context, const char
 
 
                if (newext) {
+                       char *p;
+
+                       if ((p = strrchr(context->cache_file, '.'))) {
+                               *p = '\0';
+                       }
+                       
                        context->cache_file = switch_core_sprintf(context->pool, "%s.%s", context->cache_file, newext);
                }