]> git.sesse.net Git - vlc/commitdiff
httplive: handle better relative urls
authorIlkka Ollakka <ileoo@videolan.org>
Wed, 20 Mar 2013 06:41:50 +0000 (08:41 +0200)
committerIlkka Ollakka <ileoo@videolan.org>
Wed, 20 Mar 2013 06:43:23 +0000 (08:43 +0200)
if path starts with / it's related to root of server and not
current path.

Fixes: #8321
modules/stream_filter/httplive.c

index 1e3973306690ea81677d2fe3e6d27878fbcbd45b..4771f79b4e0026bc89a507dd72b2b6c4fbe6b2ef 100644 (file)
@@ -547,10 +547,18 @@ static char *relative_URI(const char *psz_url, const char *psz_path)
     if (strncmp(psz_path, "http", 4) == 0)
         return NULL;
 
-    char    *path_end = strrchr(psz_url, '/');
-    if (path_end == NULL)
+    char *path_separator=NULL;
+    if( psz_path[0] == '/' ) //Relative URL with absolute path
+    {
+        //Try to find separator for name and path, try to skip
+        //access and first ://
+        path_separator = strchr( &psz_url[8], '/');
+    } else {
+        path_separator = strrchr(psz_url, '/');
+    }
+    if ( unlikely( path_separator == NULL ) )
         return NULL;
-    unsigned int    url_length = path_end - psz_url + 1;
+    const size_t url_length = path_separator - psz_url + 1;
     char    *psz_res = malloc(url_length + strlen(psz_path) + 1);
     strncpy(psz_res, psz_url, url_length);
     psz_res[url_length] = 0;