src/share/classes/java/net/URI.java
Print this page
*** 1827,1851 ****
sb.append(port);
}
} else if (authority != null) {
sb.append("//");
if (authority.startsWith("[")) {
int end = authority.indexOf("]");
! if (end != -1 && authority.indexOf(":")!=-1) {
! String doquote, dontquote;
if (end == authority.length()) {
dontquote = authority;
doquote = "";
} else {
! dontquote = authority.substring(0,end+1);
! doquote = authority.substring(end+1);
}
! 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,
H_REG_NAME | H_SERVER));
}
--- 1827,1853 ----
sb.append(port);
}
} else if (authority != null) {
sb.append("//");
if (authority.startsWith("[")) {
+ // authority should (but may not) contain an embedded IPv6 address
int end = authority.indexOf("]");
! 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);
}
! }
! 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,
H_REG_NAME | H_SERVER));
}