提交 e0bbf43e 编写于 作者: C chegar

7023363: URI("ftp", "[www.abc.com]", "/dir1/dir2", "query", "frag") should throw URISyntaxException

Reviewed-by: alanb, michaelm
上级 eebd2715
......@@ -1829,21 +1829,23 @@ public final class URI
} else if (authority != null) {
sb.append("//");
if (authority.startsWith("[")) {
// authority should (but may not) contain an embedded IPv6 address
int end = authority.indexOf("]");
if (end != -1 && authority.indexOf(":")!=-1) {
String doquote, dontquote;
String doquote = authority, dontquote = "";
if (end != -1 && authority.indexOf(":") != -1) {
// the authority contains an IPv6 address
if (end == authority.length()) {
dontquote = authority;
doquote = "";
} else {
dontquote = authority.substring(0,end+1);
doquote = authority.substring(end+1);
dontquote = authority.substring(0 , end + 1);
doquote = authority.substring(end + 1);
}
sb.append (dontquote);
}
sb.append(dontquote);
sb.append(quote(doquote,
L_REG_NAME | L_SERVER,
H_REG_NAME | H_SERVER));
}
} else {
sb.append(quote(authority,
L_REG_NAME | L_SERVER,
......
......@@ -23,7 +23,7 @@
/* @test
* @summary Unit test for java.net.URI
* @bug 4464135 4505046 4503239 4438319 4991359 4866303
* @bug 4464135 4505046 4503239 4438319 4991359 4866303 7023363
* @author Mark Reinhold
*/
......@@ -1050,6 +1050,13 @@ public class Test {
test("http://1.2.3.4.5").psa().x().z();
test("http://[1.2.3.4:5]").x().z();
test("http://1:2:3:4:5:6:7:8").psa().x().z();
test("http://[1.2.3.4]/").x().z();
test("http://[1.2.3.4/").x().z();
test("http://[foo]/").x().z();
test("http://[foo/").x().z();
test("s", "[foo]", "/", null, null).x().z();
test("s", "[foo", "/", null, null).x().z();
test("s", "[::foo", "/", null, null).x().z();
// Test hostnames that might initially look like IPv4 addresses
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册