7041800: URI.equals may incorrectly return true with escaped octets

Reviewed-by: alanb, michaelm
This commit is contained in:
Chris Hegarty 2011-09-01 13:53:59 +01:00
parent db62441424
commit bfeee8da4d
2 changed files with 5 additions and 1 deletions

View File

@ -1711,6 +1711,8 @@ public final class URI
i++; i++;
continue; continue;
} }
if (d != '%')
return false;
i++; i++;
if (toLower(s.charAt(i)) != toLower(t.charAt(i))) if (toLower(s.charAt(i)) != toLower(t.charAt(i)))
return false; return false;

View File

@ -23,7 +23,7 @@
/* @test /* @test
* @summary Unit test for java.net.URI * @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 * @author Mark Reinhold
*/ */
@ -1428,6 +1428,8 @@ public class Test {
gt(s, new URI("http://jag:CafeBabe@java.sun.com:94/b/c/d?q#f")); 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?r#f"));
lt(s, new URI("http://jag:cafebabe@java.sun.com:94/b/c/d?q#g")); 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("p", "s:p");
lt("s:p", "T:p"); lt("s:p", "T:p");