changeset 4368:d7044475a604

7041800: URI.equals may incorrectly return true with escaped octets Reviewed-by: alanb, michaelm
author chegar
date Thu, 01 Sep 2011 13:53:59 +0100
parents e1077ba4f0f1
children 370e70f40ea7
files src/share/classes/java/net/URI.java test/java/net/URI/Test.java
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/net/URI.java	Fri Sep 02 17:34:46 2011 +0400
+++ b/src/share/classes/java/net/URI.java	Thu Sep 01 13:53:59 2011 +0100
@@ -1711,6 +1711,8 @@
                     i++;
                     continue;
                 }
+                if (d != '%')
+                    return false;
                 i++;
                 if (toLower(s.charAt(i)) != toLower(t.charAt(i)))
                     return false;
--- a/test/java/net/URI/Test.java	Fri Sep 02 17:34:46 2011 +0400
+++ b/test/java/net/URI/Test.java	Thu Sep 01 13:53:59 2011 +0100
@@ -23,7 +23,7 @@
 
 /* @test
  * @summary Unit test for java.net.URI
- * @bug 4464135 4505046 4503239 4438319 4991359 4866303 7023363
+ * @bug 4464135 4505046 4503239 4438319 4991359 4866303 7023363 7041800
  * @author Mark Reinhold
  */
 
@@ -1428,6 +1428,8 @@
         gt(s, new URI("http://jag:CafeBabe@java.sun.com:94/b/c/d?q#f"));
         lt(s, new URI("http://jag:cafebabe@java.sun.com:94/b/c/d?r#f"));
         lt(s, new URI("http://jag:cafebabe@java.sun.com:94/b/c/d?q#g"));
+        eq(new URI("http://host/a%00bcd"), new URI("http://host/a%00bcd"));
+        ne(new URI("http://host/a%00bcd"), new URI("http://host/aZ00bcd"));
 
         lt("p", "s:p");
         lt("s:p", "T:p");