diff --git a/src/share/classes/java/net/URI.java b/src/share/classes/java/net/URI.java index 879b2b75e45f08f023501d821fb729d620ee7e47..f8417c59ba72d2516ebd85845c67883f7b4df480 100644 --- a/src/share/classes/java/net/URI.java +++ b/src/share/classes/java/net/URI.java @@ -2491,6 +2491,8 @@ public final class URI // Tell whether the given character is permitted by the given mask pair private static boolean match(char c, long lowMask, long highMask) { + if (c == 0) // 0 doesn't have a slot in the mask. So, it never matches. + return false; if (c < 64) return ((1L << c) & lowMask) != 0; if (c < 128) diff --git a/test/java/net/URI/Test.java b/test/java/net/URI/Test.java index 6e84c24264e6cc23ea0a528d50ac69fc7d5e30fe..25b19baf8356361696e34e7f7bee3a6c9eaa433a 100644 --- a/test/java/net/URI/Test.java +++ b/test/java/net/URI/Test.java @@ -1091,6 +1091,7 @@ public class Test { test("").p("").sp("").z(); + header("Emptiness"); // Components that may be empty @@ -1321,6 +1322,11 @@ public class Test { .sp("//host/foo%20bar/a/b/c/resolve").s("http") .pd("/foo bar/a/b/c/resolve").h("host") .p("/foo%20bar/a/b/c/resolve").z(); + + // 6773270: java.net.URI fails to escape u0000 + test("s", "a", "/\u0000", null) + .s("s").p("/%00").h("a") + .ta("s://a/%00").z(); }