fixes to yacyURL - more exceptions in case that urls are strange

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@5657 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 7542336ae5
commit c728879ab8

@ -92,7 +92,7 @@ public class yacyURL implements Serializable {
} }
path = "/"; path = "/";
} else { } else {
host = url.substring(p + 3, q); host = url.substring(p + 3, q).trim();
if ((r = host.indexOf('@')) < 0) { if ((r = host.indexOf('@')) < 0) {
userInfo = null; userInfo = null;
} else { } else {
@ -101,7 +101,8 @@ public class yacyURL implements Serializable {
} }
path = url.substring(q); path = url.substring(q);
} }
if (host.length() < 4) throw new MalformedURLException("host too short: '" + host + "'");
if (host.indexOf('&') >= 0) throw new MalformedURLException("invalid '&' in host");
path = resolveBackpath(path); path = resolveBackpath(path);
identPort(url, (protocol.equals("http") ? 80 : ((protocol.equals("https")) ? 443 : ((protocol.equals("ftp")) ? 21 : -1)))); identPort(url, (protocol.equals("http") ? 80 : ((protocol.equals("https")) ? 443 : ((protocol.equals("ftp")) ? 21 : -1))));
identRef(); identRef();
@ -871,8 +872,8 @@ public class yacyURL implements Serializable {
public static void main(final String[] args) { public static void main(final String[] args) {
final String[][] test = new String[][]{ final String[][] test = new String[][]{
new String[]{null, "http://www.anomic.de/test/"}, new String[]{null, "http://www.anomic.de/test/"},
new String[]{null, "http://www.anomic.de/"}, new String[]{null, "http://www.anomic.de/"},
new String[]{null, "http://www.anomic.de"}, new String[]{null, "http://www.anomic.de"},
new String[]{null, "http://www.anomic.de/home/test?x=1#home"}, new String[]{null, "http://www.anomic.de/home/test?x=1#home"},
new String[]{null, "http://www.anomic.de/home/test?x=1"}, new String[]{null, "http://www.anomic.de/home/test?x=1"},

Loading…
Cancel
Save