demux/playlist/xspf: fix input-item uri creation
authorFilip Roséen <filip@atch.se>
Thu, 13 Oct 2016 20:43:13 +0000 (22:43 +0200)
committerThomas Guillem <thomas@gllm.fr>
Fri, 28 Oct 2016 17:08:12 +0000 (19:08 +0200)
The previous implementation inaccurately treated "p_sys->psz_base" as
if it was referring to whatever directory (uri-wise) that contains the
playlist we are currently processing.

Given that this is not the case, it would not handle relative paths
correctly.

These changes make sure that we use ProcessMRL to properly handle the
paths found within the playlist (the function handles both absolute
and relative ones).

fixes #17506

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
modules/demux/playlist/xspf.c

index 5dfbfe4..16ee1b3 100644 (file)
@@ -484,24 +484,19 @@ static bool parse_track_node COMPLEX_INTERFACE
             if (psz_value == NULL)
                 input_item_SetURI(p_new_input, "vlc://nop");
             else
-            /* FIXME (#4005): This is broken. Scheme-relative (//...) locations
-             * and anchors (#...) are not resolved correctly. Also,
-             * host-relative (/...) and directory-relative locations
-             * ("relative path" in vernacular) should be resolved.
-             * -- Courmisch */
-            if (p_sys->psz_base && !strstr(psz_value, "://"))
             {
-                char* psz_tmp;
-                if (asprintf(&psz_tmp, "%s%s", p_sys->psz_base, psz_value)
-                    == -1)
+                char* psz_uri = ProcessMRL( psz_value, p_sys->psz_base );
+
+                if( !psz_uri )
                 {
+                    msg_Warn( p_demux, "unable to process MRL: %s", psz_value );
                     goto end;
                 }
-                input_item_SetURI(p_new_input, psz_tmp);
-                free(psz_tmp);
+
+                input_item_SetURI(p_new_input, psz_uri);
+                free(psz_uri);
             }
-            else
-                input_item_SetURI(p_new_input, psz_value);
+
             input_item_CopyOptions(p_new_input, p_input_item);
         }
         else