[vlc-devel] [PATCH] Demux/Playlist: If an URI contains whitespaces, it will now be encoded to %20. Fixes #2924.
Thomas Siegbert
sith_dev at gmx.eu
Sun Jan 1 17:37:04 CET 2012
---
modules/demux/playlist/playlist.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index 00b44a3..9a38a62 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -175,6 +175,34 @@ char *FindPrefix( demux_t *p_demux )
}
/**
+ * Encode only the white spaces within an URI according to RFC3986.
+ */
+char *demux_encodeUriSpaces( const char *psz_uri )
+{
+ char *psz_result = malloc( strlen( psz_uri ) * 3 + 1 ), *psz_buf = psz_result;
+
+ while( *psz_uri )
+ {
+ if ( *psz_uri == ' ' )
+ {
+ *psz_buf++ = '%';
+ *psz_buf++ = '2';
+ *psz_buf++ = '0';
+ }
+ else
+ {
+ *psz_buf++ = *psz_uri;
+ }
+
+ psz_uri++;
+ }
+
+ *psz_buf = '\0';
+
+ return psz_result;
+}
+
+/**
* Add the directory part of the playlist file to the start of the
* mrl, if the mrl is a relative file path
*/
@@ -189,6 +217,7 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
/* Simple cases first */
if( !psz_mrl || !*psz_mrl )
return NULL;
+
if( !psz_prefix || !*psz_prefix )
goto uri;
@@ -202,7 +231,8 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
goto uri;
#endif
if( strstr( psz_mrl, "://" ) )
- return strdup( psz_mrl );
+ /* White spaces of the URI have to be encoded (#2924) */
+ return strdup( demux_encodeUriSpaces( psz_mrl ) );
/* This a relative path, prepend the prefix */
char *ret;
@@ -212,6 +242,7 @@ char *ProcessMRL( const char *psz_mrl, const char *psz_prefix )
|| asprintf( &ret, "%s%s", psz_prefix, postfix ) == -1 )
ret = NULL;
free( postfix );
+
return ret;
uri:
--
1.7.5.4
More information about the vlc-devel
mailing list