Commit d710b22a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Partially fix encoding of relative paths in playlist files

parent ec70eaa0
...@@ -31,6 +31,10 @@ ...@@ -31,6 +31,10 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_url.h>
#ifdef WIN32
# include <ctype.h>
#endif
#include "playlist.h" #include "playlist.h"
...@@ -225,19 +229,31 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix ) ...@@ -225,19 +229,31 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
* PB: on some file systems, ':' are valid characters though */ * PB: on some file systems, ':' are valid characters though */
/* Simple cases first */ /* Simple cases first */
if( !psz_mrl || !*psz_mrl ) return NULL; if( !psz_mrl || !*psz_mrl )
if( !psz_prefix || !*psz_prefix ) return strdup( psz_mrl ); return NULL;
if( !psz_prefix || !*psz_prefix )
goto uri;
/* Check if the line specifies an absolute path */ /* Check if the line specifies an absolute path */
if( *psz_mrl == '/' || *psz_mrl == '\\' ) return strdup( psz_mrl ); /* FIXME: that's wrong if the playlist is not a local file */
if( *psz_mrl == DIR_SEP_CHAR )
/* Check if the line specifies an mrl/url goto uri;
* (and on win32, contains a drive letter) */ #ifdef WIN32
if( strchr( psz_mrl, ':' ) ) return strdup( psz_mrl ); /* Drive letter (this assumes URL scheme are not a single character) */
if( isalpha(psz_mrl[0]) && psz_mrl[1] == ':' )
goto uri;
#endif
/* This a relative path, prepend the prefix */ /* This a relative path, prepend the prefix */
char *ret; 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; ret = NULL;
free( postfix );
return ret; return ret;
uri:
return make_URI( psz_mrl );
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment