From 026875dd5256051d4e3504f1d9b01f7ce2bb70ff Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 3 Oct 2015 11:44:02 +0200 Subject: Bug 1243 - Fix IOUtil.cleanPathString(..) special case ; Allow IOUtil and Uri to handle relative path Fix IOUtil.cleanPathString(..) special case: Special case '/a/./../b' -> '/b' requires to resolve './' before '../'. Allow IOUtil and Uri to handle relative path: - IOUtil.getParentOf(..) - IOUtil.cleanPathString(..) Handle cases: 'a/./../b' -> 'b' '.././b' -> '../b' - Uri: Handle null scheme --- src/junit/com/jogamp/common/net/TestUri01.java | 32 ++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'src/junit/com/jogamp/common/net/TestUri01.java') diff --git a/src/junit/com/jogamp/common/net/TestUri01.java b/src/junit/com/jogamp/common/net/TestUri01.java index 1173610..4205de1 100644 --- a/src/junit/com/jogamp/common/net/TestUri01.java +++ b/src/junit/com/jogamp/common/net/TestUri01.java @@ -247,6 +247,20 @@ public class TestUri01 extends SingletonJunitCase { @Test public void test08NormalizedHierarchy() throws IOException, URISyntaxException { + { + final Uri input = Uri.cast("./dummy/nop/../a.txt"); + final Uri expected = Uri.cast("dummy/a.txt"); + URIDumpUtil.showUri(input); + final Uri normal = input.getNormalized(); + Assert.assertEquals(expected, normal); + } + { + final Uri input = Uri.cast("../dummy/nop/../a.txt"); + final Uri expected = Uri.cast("../dummy/a.txt"); + URIDumpUtil.showUri(input); + final Uri normal = input.getNormalized(); + Assert.assertEquals(expected, normal); + } { final Uri input = Uri.cast("http://localhost/dummy/../"); final Uri expected = Uri.cast("http://localhost/"); @@ -255,7 +269,21 @@ public class TestUri01 extends SingletonJunitCase { Assert.assertEquals(expected, normal); } { - final Uri input = Uri.cast("http://localhost/test/dummy/../text.txt"); + final Uri input = Uri.cast("http://localhost/dummy/./../"); + final Uri expected = Uri.cast("http://localhost/"); + URIDumpUtil.showUri(input); + final Uri normal = input.getNormalized(); + Assert.assertEquals(expected, normal); + } + { + final Uri input = Uri.cast("http://localhost/dummy/../aa/././../"); + final Uri expected = Uri.cast("http://localhost/"); + URIDumpUtil.showUri(input); + final Uri normal = input.getNormalized(); + Assert.assertEquals(expected, normal); + } + { + final Uri input = Uri.cast("http://localhost/test/dummy/./../text.txt"); final Uri expected = Uri.cast("http://localhost/test/text.txt"); URIDumpUtil.showUri(input); final Uri normal = input.getNormalized(); @@ -280,7 +308,7 @@ public class TestUri01 extends SingletonJunitCase { Assert.assertEquals(expected, normal); } { - final Uri input = Uri.cast("jar:http://localhost/test/dummy/../abc.jar!/"); + final Uri input = Uri.cast("jar:http://localhost/test/./dummy/../abc.jar!/"); final Uri expected = Uri.cast("jar:http://localhost/test/abc.jar!/"); URIDumpUtil.showUri(input); final Uri normal = input.getNormalized(); -- cgit v1.2.3