[vlc-commits] commit: Partially fix encoding of relative paths in playlist files ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Sun Mar 7 11:33:20 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 7 12:33:07 2010 +0200| [d710b22ac825daff7497e73afacdc400235748cf] | committer: Rémi Denis-Courmont
Partially fix encoding of relative paths in playlist files
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d710b22ac825daff7497e73afacdc400235748cf
---
modules/demux/playlist/playlist.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index f6ea892..cd8a264 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -31,6 +31,10 @@
#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"
@@ -225,19 +229,31 @@ 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
/* 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 );
}
More information about the vlc-commits
mailing list