[FFmpeg-devel] [PATCH v3 2/2] avformat/tests/url: add test cases for .. and last node is ..

Steven Liu lq at chinaffmpeg.org
Mon Jul 27 16:07:48 EEST 2020


Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
---
 libavformat/tests/url.c | 14 ++++++++++++++
 tests/ref/fate/url      | 12 ++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c
index 1d961a1b43..0de511caf9 100644
--- a/libavformat/tests/url.c
+++ b/libavformat/tests/url.c
@@ -24,6 +24,8 @@
 static void test(const char *base, const char *rel)
 {
     char buf[200], buf2[200];
+    memset(buf, 0, 200);
+    memset(buf2, 0, 200);
     ff_make_absolute_url(buf, sizeof(buf), base, rel);
     printf("%50s %-20s => %s\n", base, rel, buf);
     if (base) {
@@ -66,7 +68,19 @@ int main(void)
     test("http://server/foo/bar?param=value/with/slashes", "/baz");
     test("http://server/foo/bar?param&otherparam", "?someparam");
     test("http://server/foo/bar", "//other/url");
+    test("http://server/foo/bar", "../other/url");
+    test("http://server/foo/bar", "other/url");
     test("http://server/foo/bar", "../../../../../other/url");
+    test("http://server/foo/bar", "../../../../../other/url/test..mp3");
+    test("http://server/foo/bar", "../../../../../other/url/test..");
+    test("http://server/foo/bar", "../../../../../other/url/test/...");
+    test("http://server/foo/bar", "../../../../../other/url/.../test/out");
+    test("http://server/foo/bar", "../../../../../other/url/.../../test/out");
+    test("http://server/foo/bar", "../../../../../other/url/.../..test/out");
+    test("http://server/foo/bar", "../../../../../other/url/..");
+    test("http://server/foo/bar", "../../../../../other/url/..mp3");
+    test("http://server/foo/bar", "../../../../../other/url/..test/mp3");
+    test("http://server/foo/bar", "../../../../../other/url/test../mp3");
     test("http://server/foo/bar", "/../../../../../other/url");
     test("http://server/foo/bar", "/test/../../../../../other/url");
     test("http://server/foo/bar", "/test/../../test/../../../other/url");
diff --git a/tests/ref/fate/url b/tests/ref/fate/url
index 533ba2cb1e..35eee25f4a 100644
--- a/tests/ref/fate/url
+++ b/tests/ref/fate/url
@@ -13,7 +13,19 @@ Testing ff_make_absolute_url:
     http://server/foo/bar?param=value/with/slashes /baz                 => http://server/baz
             http://server/foo/bar?param&otherparam ?someparam           => http://server/foo/bar?someparam
                              http://server/foo/bar //other/url          => http://other/url
+                             http://server/foo/bar ../other/url => http://server/other/url
+                             http://server/foo/bar other/url => http://server/foo/other/url
                              http://server/foo/bar ../../../../../other/url => http://server/other/url
+                             http://server/foo/bar ../../../../../other/url/test..mp3 => http://server/other/url/test..mp3
+                             http://server/foo/bar ../../../../../other/url/test.. => http://server/other/url/test..
+                             http://server/foo/bar ../../../../../other/url/test/... => http://server/other/url/test/...
+                             http://server/foo/bar ../../../../../other/url/.../test/out => http://server/other/url/.../test/out
+                             http://server/foo/bar ../../../../../other/url/.../../test/out => http://server/other/url/test/out
+                             http://server/foo/bar ../../../../../other/url/.../..test/out => http://server/other/url/.../..test/out
+                             http://server/foo/bar ../../../../../other/url/.. => http://server/other
+                             http://server/foo/bar ../../../../../other/url/..mp3 => http://server/other/url/..mp3
+                             http://server/foo/bar ../../../../../other/url/..test/mp3 => http://server/other/url/..test/mp3
+                             http://server/foo/bar ../../../../../other/url/test../mp3 => http://server/other/url/test../mp3
                              http://server/foo/bar /../../../../../other/url => http://server/other/url
                              http://server/foo/bar /test/../../../../../other/url => http://server/other/url
                              http://server/foo/bar /test/../../test/../../../other/url => http://server/other/url
-- 
2.25.0





More information about the ffmpeg-devel mailing list