]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/playlist.c
MP4: Recognize \xa9wrt
[vlc] / modules / demux / playlist / playlist.c
index 6706f3051021bb436e3542ae4792568119de2cb1..de14c4a4411232511b2e7b9bef451de3177ca2dd 100644 (file)
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_demux.h>
+#include <vlc_url.h>
+#ifdef WIN32
+# include <ctype.h>
+#endif
 
 #include "playlist.h"
 
@@ -57,8 +61,7 @@ vlc_module_begin ()
     add_bool( "playlist-autostart", true, NULL,
               AUTOSTART_TEXT, AUTOSTART_LONGTEXT, false )
 
-    add_integer( "parent-item", 0, NULL, NULL, NULL, true )
-        change_internal ()
+    add_obsolete_integer( "parent-item" ) /* removed since 1.1.0 */
 
     add_bool( "playlist-skip-ads", true, NULL,
               SKIP_ADS_TEXT, SKIP_ADS_LONGTEXT, false )
@@ -69,6 +72,7 @@ vlc_module_begin ()
         set_description( N_("M3U playlist import") )
         add_shortcut( "playlist" )
         add_shortcut( "m3u" )
+        add_shortcut( "m3u8" )
         add_shortcut( "m3u-open" )
         set_capability( "demux", 10 )
         set_callbacks( Import_M3U, Close_M3U )
@@ -191,7 +195,8 @@ char *FindPrefix( demux_t *p_demux )
     }
     else
     {
-        if( asprintf( &psz_path,"%s", p_demux->psz_path ) == -1 )
+        psz_path = strdup( p_demux->psz_path );
+        if( psz_path == NULL )
             return NULL;
     }
 
@@ -223,19 +228,33 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
      * PB: on some file systems, ':' are valid characters though */
 
     /* Simple cases first */
-    if( !psz_mrl || !*psz_mrl ) return NULL;
-    if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl );
+    if( !psz_mrl || !*psz_mrl )
+        return NULL;
+    if( !psz_prefix || !*psz_prefix )
+        goto uri;
 
     /* Check if the line specifies an absolute path */
-    if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl );
-
-    /* Check if the line specifies an mrl/url
-     * (and on win32, contains a drive letter) */
-    if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl );
+    /* FIXME: that's wrong if the playlist is not a local file */
+    if( *psz_mrl == DIR_SEP_CHAR )
+        goto uri;
+#ifdef WIN32
+    /* Drive letter (this assumes URL scheme are not a single character) */
+    if( isalpha(psz_mrl[0]) && psz_mrl[1] == ':' )
+        goto uri;
+#endif
+    if( strstr( psz_mrl, "://" ) )
+        return strdup( psz_mrl );
 
     /* This a relative path, prepend the prefix */
     char *ret;
-    if( asprintf( &ret, "%s%s", psz_prefix, psz_mrl ) == -1 )
+    char *postfix = encode_URI_component( psz_mrl );
+    /* FIXME: postfix may not be encoded correctly (esp. slashes) */
+    if( postfix == NULL
+     || asprintf( &ret, "%s%s", psz_prefix, postfix ) == -1 )
         ret = NULL;
+    free( postfix );
     return ret;
+
+uri:
+    return make_URI( psz_mrl );
 }