mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
Merge
This commit is contained in:
commit
f08a9de3b2
43 changed files with 942 additions and 256 deletions
|
@ -45,6 +45,7 @@ import java.util.ServiceLoader;
|
|||
|
||||
import jdk.internal.access.JavaNetURLAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import sun.net.util.IPAddressUtil;
|
||||
import sun.security.util.SecurityConstants;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
|
@ -466,13 +467,19 @@ public final class URL implements java.io.Serializable {
|
|||
this.file = path;
|
||||
}
|
||||
|
||||
// Note: we don't do validation of the URL here. Too risky to change
|
||||
// Note: we don't do full validation of the URL here. Too risky to change
|
||||
// right now, but worth considering for future reference. -br
|
||||
if (handler == null &&
|
||||
(handler = getURLStreamHandler(protocol)) == null) {
|
||||
throw new MalformedURLException("unknown protocol: " + protocol);
|
||||
}
|
||||
this.handler = handler;
|
||||
if (host != null && isBuiltinStreamHandler(handler)) {
|
||||
String s = IPAddressUtil.checkExternalForm(this);
|
||||
if (s != null) {
|
||||
throw new MalformedURLException(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1038,7 +1045,12 @@ public final class URL implements java.io.Serializable {
|
|||
* @since 1.5
|
||||
*/
|
||||
public URI toURI() throws URISyntaxException {
|
||||
return new URI (toString());
|
||||
URI uri = new URI(toString());
|
||||
if (authority != null && isBuiltinStreamHandler(handler)) {
|
||||
String s = IPAddressUtil.checkAuthority(this);
|
||||
if (s != null) throw new URISyntaxException(authority, s);
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1635,6 +1647,10 @@ public final class URL implements java.io.Serializable {
|
|||
return replacementURL;
|
||||
}
|
||||
|
||||
boolean isBuiltinStreamHandler(URLStreamHandler handler) {
|
||||
return isBuiltinStreamHandler(handler.getClass().getName());
|
||||
}
|
||||
|
||||
private boolean isBuiltinStreamHandler(String handlerClassName) {
|
||||
return (handlerClassName.startsWith(BUILTIN_HANDLERS_PREFIX));
|
||||
}
|
||||
|
|
|
@ -516,12 +516,15 @@ public abstract class URLStreamHandler {
|
|||
* different from this one
|
||||
* @since 1.3
|
||||
*/
|
||||
protected void setURL(URL u, String protocol, String host, int port,
|
||||
protected void setURL(URL u, String protocol, String host, int port,
|
||||
String authority, String userInfo, String path,
|
||||
String query, String ref) {
|
||||
if (this != u.handler) {
|
||||
throw new SecurityException("handler for url different from " +
|
||||
"this handler");
|
||||
} else if (host != null && u.isBuiltinStreamHandler(this)) {
|
||||
String s = IPAddressUtil.checkHostString(host);
|
||||
if (s != null) throw new IllegalArgumentException(s);
|
||||
}
|
||||
// ensure that no one can reset the protocol on a given URL.
|
||||
u.set(u.getProtocol(), host, port, authority, userInfo, path, query, ref);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue