]> git.sesse.net Git - vlc/blobdiff - modules/demux/playlist/m3u.c
m3u: assume m3u with BOM at start as utf-8 encoded.
[vlc] / modules / demux / playlist / m3u.c
index aaa8ab0ace5e6845c01f840054425c341b079151..f3ba6114ba74560c8d6f780c6b1d40ff23584c4c 100644 (file)
@@ -46,7 +46,6 @@ struct demux_sys_t
  * Local prototypes
  *****************************************************************************/
 static int Demux( demux_t *p_demux);
-static int Control( demux_t *p_demux, int i_query, va_list args );
 static void parseEXTINF( char *psz_string, char **ppsz_artist, char **ppsz_name, int *pi_duration );
 static bool ContainsURL( demux_t *p_demux );
 
@@ -55,6 +54,11 @@ static char *GuessEncoding (const char *str)
     return IsUTF8 (str) ? strdup (str) : FromLatin1 (str);
 }
 
+static char *CheckUnicode (const char *str)
+{
+    return IsUTF8 (str) ? strdup (str): NULL;
+}
+
 /*****************************************************************************
  * Import_M3U: main import function
  *****************************************************************************/
@@ -66,9 +70,10 @@ int Import_M3U( vlc_object_t *p_this )
     char *(*pf_dup) (const char *);
 
     if( POKE( p_peek, "RTSPtext", 8 ) /* QuickTime */
+     || POKE( p_peek, "\xef\xbb\xbf" "#EXTM3U", 10) /* BOM at start */
      || demux_IsPathExtension( p_demux, ".m3u8" )
      || demux_IsForced( p_demux, "m3u8" ) )
-        pf_dup = strdup; /* UTF-8 */
+        pf_dup = CheckUnicode; /* UTF-8 */
     else
     if( POKE( p_peek, "#EXTM3U", 7 )
      || demux_IsPathExtension( p_demux, ".m3u" )
@@ -97,7 +102,7 @@ static bool ContainsURL( demux_t *p_demux )
 
     while( p_peek + sizeof( "https://" ) < p_peek_end )
     {
-        /* One line starting with an URL is enough */
+        /* One line starting with a URL is enough */
         if( !strncasecmp( (const char *)p_peek, "http://", 7 ) ||
             !strncasecmp( (const char *)p_peek, "mms://", 6 ) ||
             !strncasecmp( (const char *)p_peek, "rtsp://", 7 ) ||
@@ -222,14 +227,14 @@ static int Demux( demux_t *p_demux )
             b_cleanup = true;
             if( !psz_mrl )
             {
-                LocaleFree( psz_parse );
+                free( psz_parse );
                 goto error;
             }
 
-            p_input = input_item_NewExt( p_demux, psz_mrl, psz_name,
+            p_input = input_item_NewExt( psz_mrl, psz_name,
                                         i_options, ppsz_options, 0, i_duration );
 
-            LocaleFree( psz_parse );
+            free( psz_parse );
             free( psz_mrl );
 
             if ( !EMPTY_STR(psz_artist) )
@@ -270,12 +275,6 @@ static int Demux( demux_t *p_demux )
     return 0; /* Needed for correct operation of go back */
 }
 
-static int Control( demux_t *p_demux, int i_query, va_list args )
-{
-    VLC_UNUSED(p_demux); VLC_UNUSED(i_query); VLC_UNUSED(args);
-    return VLC_EGENERIC;
-}
-
 static void parseEXTINF(char *psz_string, char **ppsz_artist,
                         char **ppsz_name, int *pi_duration)
 {