[vlc-devel] [PATCH] demux/playlist: ProcessMRL: fallback to original if valid scheme
Filip Roséen
filip at atch.se
Thu Mar 23 03:07:07 CET 2017
The changes introduced in 36bee77 had the unfortunate side-effect that
location-data that could not be parsed as a URL would be discarded,
for example an xspf playlist containing the line below would simply
ignore it (due to ProcessMRL rejecting it):
> dvb-t://frequency=674000000:inversion=-1:bandwidth=8:code-rate-hp=2/3:code-rate-lp=1/2:modulation=64QAM:transmission=8:guard=1/32:
In order to fix the issue while still allowing uri-resolving for
URI-valid entities, the following changes make sure that we retain the
original string if it contains "://" and all prior characters are
valid in a scheme.
fixes: #18155
---
modules/demux/playlist/playlist.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index ef80a55a33..b2b7b7cfb9 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -230,6 +230,8 @@ char *FindPrefix(demux_t *p_demux)
*/
char *ProcessMRL(const char *str, const char *base)
{
+ char const* orig = str;
+
if (str == NULL)
return NULL;
@@ -267,6 +269,25 @@ char *ProcessMRL(const char *str, const char *base)
char *abs = vlc_uri_resolve(base, str);
free(rel);
+
+ if (abs == NULL)
+ {
+ /** If the input is not a valid URL, see if there is a scheme:// where
+ * the scheme itself consists solely of valid scheme-characters
+ * (including the VLC's scheme-extension). If it does, fall back to
+ * allowing the URI in order to not break back-compatibility.
+ */
+ char const* scheme_end = strstr( orig, "://" );
+ char const* valid_chars = "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789" "+-./";
+ if (scheme_end &&
+ strspn (orig, valid_chars) == (size_t)(scheme_end - orig))
+ {
+ abs = strdup (orig);
+ }
+ }
+
return abs;
}
--
2.12.0
More information about the vlc-devel
mailing list