From patchwork Tue Jul 28 04:10:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zlomek, Josef" X-Patchwork-Id: 21332 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id ED8EE44B957 for ; Tue, 28 Jul 2020 07:11:07 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C356968B935; Tue, 28 Jul 2020 07:11:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vps.zlomek.net (vps.zlomek.net [195.181.211.90]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5583E68B89F for ; Tue, 28 Jul 2020 07:11:01 +0300 (EEST) Received: by vps.zlomek.net (Postfix, from userid 1000) id 933035FE4E; Tue, 28 Jul 2020 06:11:00 +0200 (CEST) From: Josef Zlomek To: ffmpeg-devel@ffmpeg.org Date: Tue, 28 Jul 2020 06:10:58 +0200 Message-Id: <20200728041058.14557-2-josef@pex.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200728041058.14557-1-josef@pex.com> References: <20200728041058.14557-1-josef@pex.com> Subject: [FFmpeg-devel] [PATCH v3 2/2] avformat/tests/url: add test cases for handling of double dot X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Josef Zlomek MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" added test cases Signed-off-by: Josef Zlomek --- libavformat/tests/url.c | 11 ++++++++++- tests/ref/fate/url | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libavformat/tests/url.c b/libavformat/tests/url.c index 1d961a1b43..029be6ff10 100644 --- a/libavformat/tests/url.c +++ b/libavformat/tests/url.c @@ -23,7 +23,7 @@ static void test(const char *base, const char *rel) { - char buf[200], buf2[200]; + char buf[80], buf2[80]; ff_make_absolute_url(buf, sizeof(buf), base, rel); printf("%50s %-20s => %s\n", base, rel, buf); if (base) { @@ -57,6 +57,9 @@ int main(void) test("/foo/bar", "../baz"); test("/foo/bar", "/baz"); test("/foo/bar", "../../../baz"); + test("/foo/bar", ".."); + test("/foo/bar/baz", ".."); + test("http://server", ""); test("http://server/foo/", "baz"); test("http://server/foo/bar", "baz"); test("http://server/foo/", "../baz"); @@ -65,11 +68,17 @@ int main(void) test("http://server/foo/bar/123", "https://other/url"); test("http://server/foo/bar?param=value/with/slashes", "/baz"); test("http://server/foo/bar?param&otherparam", "?someparam"); + test("http://server/foo/bar", "simple/relative/path"); test("http://server/foo/bar", "//other/url"); test("http://server/foo/bar", "../../../../../other/url"); + test("http://server/foo/bar", "a/b/../c/d/../e../..f/.../other/url/test..mp3"); + test("http://server/foo/bar", "/a/b/../c/d/../e../..f/.../other/url/test..mp3"); + test("http://server/foo/bar", "a/b/../c/d/../e../..f/.../other/url/.."); + test("http://server/foo/bar", "a/b/../c/d/../e../..f/.../other/url/"); test("http://server/foo/bar", "/../../../../../other/url"); test("http://server/foo/bar", "/test/../../../../../other/url"); test("http://server/foo/bar", "/test/../../test/../../../other/url"); + test("http://server/foo/bar", "/too/long1/too/long2/too/long3/too/long4/too/long5/too/long6/too/long7"); printf("\nTesting av_url_split:\n"); test2("/foo/bar"); diff --git a/tests/ref/fate/url b/tests/ref/fate/url index 533ba2cb1e..20c37bc826 100644 --- a/tests/ref/fate/url +++ b/tests/ref/fate/url @@ -4,6 +4,9 @@ Testing ff_make_absolute_url: /foo/bar ../baz => /baz /foo/bar /baz => /baz /foo/bar ../../../baz => /baz + /foo/bar .. => / + /foo/bar/baz .. => /foo/ + http://server => http://server http://server/foo/ baz => http://server/foo/baz http://server/foo/bar baz => http://server/foo/baz http://server/foo/ ../baz => http://server/baz @@ -12,11 +15,17 @@ Testing ff_make_absolute_url: http://server/foo/bar/123 https://other/url => https://other/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 simple/relative/path => http://server/foo/simple/relative/path http://server/foo/bar //other/url => http://other/url http://server/foo/bar ../../../../../other/url => http://server/other/url + http://server/foo/bar a/b/../c/d/../e../..f/.../other/url/test..mp3 => http://server/foo/a/c/e../..f/.../other/url/test..mp3 + http://server/foo/bar /a/b/../c/d/../e../..f/.../other/url/test..mp3 => http://server/a/c/e../..f/.../other/url/test..mp3 + http://server/foo/bar a/b/../c/d/../e../..f/.../other/url/.. => http://server/foo/a/c/e../..f/.../other/ + http://server/foo/bar a/b/../c/d/../e../..f/.../other/url/ => http://server/foo/a/c/e../..f/.../other/url/ 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 + http://server/foo/bar /too/long1/too/long2/too/long3/too/long4/too/long5/too/long6/too/long7 => http://server/too/long1/too/long2/too/long3/too/long4/too/long5/too/long6/too/l Testing av_url_split: /foo/bar => -1 /foo/bar