diff options
author | Sven Gothel <[email protected]> | 2014-09-07 07:58:39 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-09-07 07:58:39 +0200 |
commit | 0b07f9107c5b033913f5c4cbeb906ae6dafc2d77 (patch) | |
tree | a2248c83cf9bb50721d195798fcb96a688224f31 /src/junit/com/jogamp/common/net/URIDumpUtil.java | |
parent | 2faec846fbc13d206028b16a7713c7a1a701fa08 (diff) |
Bug 908: Fix URI/URL double encoding, ensuring encoded/decoded variants are used properly (Added unit test)
Bug 908 was caused by confusing URI encoded parts (e.g. scheme-specific-part) and it's decoded variant.
This especially happened due to:
- the fact, that the encoded and unencoded variant uses the same String type,
- the URI/URL decoding differs, is not complete (e.g. %20 .. SPACE remains in decoded part),
- and does not comply w/ RFC 2396 and RFC 3986 (encoding), e.g. not all RESERVED chars are encoded.
In branch 'v2.3.0_branch', we will introduce our own Uri and Uri.Encoded class
to solve above issue by replacing all URI usage w/ Uri.
- Backporting results of own Uri class introduction in branch 'v2.3.0_branch'
- Ensure the encoded URI parts are used where required, i.e. IOUtil.compose(..) etc
- TestNetIOURIReservedCharsBug908: Automated test, launching GlueGen jar file from an <i>odd pathname</i>.
Diffstat (limited to 'src/junit/com/jogamp/common/net/URIDumpUtil.java')
-rw-r--r-- | src/junit/com/jogamp/common/net/URIDumpUtil.java | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/junit/com/jogamp/common/net/URIDumpUtil.java b/src/junit/com/jogamp/common/net/URIDumpUtil.java index 8d94b6d..1a74742 100644 --- a/src/junit/com/jogamp/common/net/URIDumpUtil.java +++ b/src/junit/com/jogamp/common/net/URIDumpUtil.java @@ -7,14 +7,14 @@ import java.net.URL; public class URIDumpUtil { public static void showURX(final String urx) throws MalformedURLException, URISyntaxException { - System.err.println("XXXXXX "+urx); + System.err.println("WWWWWW "+urx); showURL(new URL(urx)); showURI(new URI(urx)); - System.err.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); + System.err.println("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"); } public static void showURL(final URL url) { - System.err.println("YYYYYY URL "+url); + System.err.println("XXXXXX URL "+url.toString()); System.err.println("protocol: "+url.getProtocol()); System.err.println("auth: "+url.getAuthority()); System.err.println("host: "+url.getHost()); @@ -22,28 +22,24 @@ public class URIDumpUtil { System.err.println("file: "+url.getFile() + " ( path " + url.getPath() + ", query " + url.getQuery() + " ) " ); System.err.println("ref: "+url.getRef()); } + public static void showURI(final URI uri) { - System.err.println("ZZZZZZ URI "+uri); - // 1 [scheme:]scheme-specific-part[#fragment] - System.err.println("1 scheme: "+uri.getScheme()); - System.err.println("1 scheme-part: "+uri.getRawSchemeSpecificPart()); - System.err.println("1 fragment: "+uri.getRawFragment()); + showURI("YYYYYY URI "+uri+", isOpaque "+uri.isOpaque()+", isAbs "+uri.isAbsolute(), uri); + } + public static void showURI(final String message, final URI uri) { + System.err.println(message); - // 2 [scheme:][//authority][path][?query][#fragment] - System.err.println("2 scheme: "+uri.getScheme()); - System.err.println("2 auth: "+uri.getRawAuthority()); - System.err.println("2 path: "+uri.getRawPath()); - System.err.println("2 query: "+uri.getRawQuery()); - System.err.println("2 fragment: "+uri.getRawFragment()); + System.err.println("0.0.0 string: "+uri.toString()); + System.err.println("0.0.0 ascii : "+uri.toASCIIString()); - // 3 [scheme:][//authority][path][?query][#fragment] - // authority: [user-info@]host[:port] - System.err.println("3 scheme: "+uri.getScheme()); - System.err.println("3 user-info: "+uri.getRawUserInfo()); - System.err.println("3 host: "+uri.getHost()); - System.err.println("3 port: "+uri.getPort()); - System.err.println("3 path: "+uri.getRawPath()); - System.err.println("3 query: "+uri.getRawQuery()); - System.err.println("3 fragment: "+uri.getRawFragment()); + System.err.println("1.0.0 scheme: "+uri.getScheme()); + System.err.println("2.0.0 scheme-part: "+uri.getRawSchemeSpecificPart()+" (raw), "+uri.getSchemeSpecificPart()+" (dec)"); + System.err.println("2.1.0 auth: "+uri.getRawAuthority()+" (raw), "+uri.getAuthority()+" (dec)"); + System.err.println("2.1.1 user-info: "+uri.getRawUserInfo()+" (raw), "+uri.getUserInfo()+" (dec)"); + System.err.println("2.1.1 host: "+uri.getHost()); + System.err.println("2.1.1 port: "+uri.getPort()); + System.err.println("2.2.0 path: "+uri.getRawPath()+" (raw), "+uri.getPath()+" (dec)"); + System.err.println("2.3.0 query: "+uri.getRawQuery()+" (raw), "+uri.getQuery()+" (dec)"); + System.err.println("3.0.0 fragment: "+uri.getRawFragment()+" (raw), "+uri.getFragment()+" (dec)"); } } |