Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

fail-save patch for pattern matching

orbiter00f63ea00d89
diff --git a/source/de/anomic/plasma/plasmaURLPattern.java b/source/de/anomic/plasma/plasmaURLPattern.java
index ddfc21946..3fd3b2c9e 100644
--- a/source/de/anomic/plasma/plasmaURLPattern.java
+++ b/source/de/anomic/plasma/plasmaURLPattern.java
@@ -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))));
}
}