fail-save patch for pattern matching

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@400 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 20 years ago
parent 0a6be961ea
commit 00f63ea00d

@ -79,10 +79,12 @@ public class plasmaURLPattern {
}
public void add(String host, String path) {
if (path.startsWith("/")) path = path.substring(1);
hostpaths.put(host, path);
}
public boolean isListed(String hostlow, String path) {
if (path.startsWith("/")) path = path.substring(1);
String pp = ""; // path-pattern
// first try to match the domain with wildcard '*'
@ -90,19 +92,19 @@ public class plasmaURLPattern {
int index = 0;
while ((index = hostlow.indexOf('.', index + 1)) != -1) {
if ((pp = (String) hostpaths.get(hostlow.substring(0, index + 1) + "*")) != null) {
return ((pp.equals("*")) || (path.substring(1).matches(pp)));
return ((pp.equals("*")) || (path.matches(pp)));
}
}
index = hostlow.length();
while ((index = hostlow.lastIndexOf('.', index - 1)) != -1) {
if ((pp = (String) hostpaths.get("*" + hostlow.substring(index, hostlow.length()))) != null) {
return ((pp.equals("*")) || (path.substring(1).matches(pp)));
return ((pp.equals("*")) || (path.matches(pp)));
}
}
// try to match without wildcard in domain
return (((pp = (String) hostpaths.get(hostlow)) != null) &&
((pp.equals("*")) || (path.substring(1).matches(pp))));
((pp.equals("*")) || (path.matches(pp))));
}
}

Loading…
Cancel
Save