]> git.sesse.net Git - ffmpeg/commitdiff
lavf/url: fix relative url parsing when the query string or fragment has a colon
authorruiquan.crq <caihaoning83@gmail.com>
Sat, 17 Oct 2020 15:17:14 +0000 (23:17 +0800)
committerMarton Balint <cus@passwd.hu>
Wed, 28 Oct 2020 20:34:09 +0000 (21:34 +0100)
This disallows the usage of ? and # in libavformat specific scheme options
(e.g. subfile,,start,32815239,end,0,,:video.ts) but this change was considered
acceptable.

Signed-off-by: ruiquan.crq <caihaoning83@gmail.com>
Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/tests/url.c
libavformat/url.c
tests/ref/fate/url

index 2440ae08bc555463e0339fb130684a034a8dd195..2eb597bb5efd42af2fe7ff87418ddbf389e58a4b 100644 (file)
@@ -90,6 +90,8 @@ int main(void)
     test_decompose("http://[::1]/dev/null");
     test_decompose("http://[::1]:8080/dev/null");
     test_decompose("//ffmpeg/dev/null");
+    test_decompose("test?url=http://server/path");
+    test_decompose("dummy.mp4#t=0:02:00,121.5");
 
     printf("Testing ff_make_absolute_url:\n");
     test(NULL, "baz");
index 3c858f0257c8c83234383e8e2f21eb7b7b702bac..6db4b4e1ae43da729a144d37e97f175f1cae287b 100644 (file)
@@ -97,7 +97,7 @@ int ff_url_decompose(URLComponents *uc, const char *url, const char *end)
 
     /* scheme */
     uc->scheme = cur;
-    p = find_delim(":/", cur, end); /* lavf "schemes" can contain options */
+    p = find_delim(":/?#", cur, end); /* lavf "schemes" can contain options but not some RFC 3986 delimiters */
     if (*p == ':')
         cur = p + 1;
 
index 7e6395c47bf69bac2aaffdbd21b4ee85b04bd527..08e80def7dd3b18d0043d07567ba26fd2d36a176 100644 (file)
@@ -43,6 +43,14 @@ http://[::1]:8080/dev/null =>
   host: ffmpeg
   path: /dev/null
 
+test?url=http://server/path =>
+  path: test
+  query: ?url=http://server/path
+
+dummy.mp4#t=0:02:00,121.5 =>
+  path: dummy.mp4
+  fragment: #t=0:02:00,121.5
+
 Testing ff_make_absolute_url:
                                             (null) baz                  => baz
                                           /foo/bar baz                  => /foo/baz