throw MalformedURLException on unknown protocol

on other than the supported   http https ftp file smb \\  mailto
pull/1/head
reger 11 years ago
parent bb8181b2be
commit 78d08998db

@ -190,6 +190,9 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
if (this.host.indexOf('&') >= 0) throw new MalformedURLException("invalid '&' in host");
this.path = resolveBackpath(this.path); // adds "/" if missing
identPort(url, (isHTTP() ? 80 : (isHTTPS() ? 443 : (isFTP() ? 21 : (isSMB() ? 445 : -1)))));
if (this.port < 0) { // none of known protocols (above) = unknown
throw new MalformedURLException("unknown protocol: " + url);
}
identAnchor();
identSearchpart();
escape();
@ -615,7 +618,7 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
try {
final String portStr = this.host.substring(r + 1);
if (portStr.trim().length() > 0) this.port = Integer.parseInt(portStr);
else this.port = -1;
else this.port = dflt;
this.host = this.host.substring(0, r);
} catch (final NumberFormatException e) {
throw new MalformedURLException("wrong port in host fragment '" + this.host + "' of input url '" + inputURL + "'");

Loading…
Cancel
Save