From 91775a1abd432d3c5a18036054e90fecc86fbb99 Mon Sep 17 00:00:00 2001 From: Alex Ashley Date: Fri, 21 Feb 2014 09:30:49 +0000 Subject: [PATCH] hlsdemux: Fix for URLs that contain a '/' in the query parameter If the URL for the master manifest files contains a '/' character in the query parameter (for example http://example.net/1054559_h264_1500k.mp4/master.m3u8?acl=/*1054559_h264_1500k.mp4), hlsdemux is incorrectly converting the relative URLs of the media playlists in to absolute URLs. It is incorrectly using the last '/' it finds in the URL. According to RFC3986 the '/' character is allowed in the query part of the URL. https://bugzilla.gnome.org/show_bug.cgi?id=725137 --- ext/hls/m3u8.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index 5cf4b0e218..b1eee74c76 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -771,7 +771,15 @@ uri_join (const gchar * uri1, const gchar * uri2) uri_copy = g_strdup (uri1); if (uri2[0] != '/') { /* uri2 is a relative uri2 */ - tmp = g_utf8_strrchr (uri_copy, -1, '/'); + /* look for query params */ + tmp = g_utf8_strchr (uri_copy, -1, '?'); + if (tmp) { + /* find last / char, ignoring query params */ + tmp = g_utf8_strrchr (uri_copy, tmp - uri_copy, '/'); + } else { + /* find last / char in URL */ + tmp = g_utf8_strrchr (uri_copy, -1, '/'); + } if (!tmp) { GST_WARNING ("Can't build a valid uri_copy"); goto out;