changeset 2403:67ea299d5501

6773270: java.net.URI fails to escape \u0000 Summary: check for \u0000 Reviewed-by: alanb
author michaelm
date Fri, 21 May 2010 07:29:48 +0100
parents 70e25a57fd02
children d01726854317
files src/share/classes/java/net/URI.java test/java/net/URI/Test.java
diffstat 2 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/net/URI.java	Thu May 20 13:57:58 2010 -0700
+++ b/src/share/classes/java/net/URI.java	Fri May 21 07:29:48 2010 +0100
@@ -2491,6 +2491,8 @@
 
     // 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)
--- a/test/java/net/URI/Test.java	Thu May 20 13:57:58 2010 -0700
+++ b/test/java/net/URI/Test.java	Fri May 21 07:29:48 2010 +0100
@@ -1091,6 +1091,7 @@
         test("").p("").sp("").z();
 
 
+
         header("Emptiness");
 
         // Components that may be empty
@@ -1321,6 +1322,11 @@
             .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();
     }