Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- remove double entries in blacklist as well
karlchenofhell3d6ab19f7e86
diff --git a/htroot/BlacklistCleaner_p.html b/htroot/BlacklistCleaner_p.htmlindex 64318a38f..df8d933ca 100644--- a/htroot/BlacklistCleaner_p.html+++ b/htroot/BlacklistCleaner_p.html@@ -36,7 +36,13 @@#{entries}#<dt><label for="select#[entry]#" class="error">- #(error)#Two wildcards in host-part::Either subdomain <u>or</u> wildcard::Path is invalid Regex::Wildcard not on begin or end::Host contains illegal chars#(/error)#+ #(error)#Two wildcards in host-part+ ::Either subdomain <u>or</u> wildcard+ ::Path is invalid Regex+ ::Wildcard not on begin or end+ ::Host contains illegal chars+ ::Double+ #(/error)#</label><input type="checkbox" name="select#[entry]#" id="select#[entry]#" checked="checked" /></dt>diff --git a/htroot/BlacklistCleaner_p.java b/htroot/BlacklistCleaner_p.javaindex 3cbc0e676..d0893233a 100644--- a/htroot/BlacklistCleaner_p.java+++ b/htroot/BlacklistCleaner_p.java@@ -51,6 +51,7 @@import java.io.File;import java.util.ArrayList;import java.util.HashMap;+import java.util.HashSet;import java.util.Iterator;import java.util.regex.Pattern;import java.util.regex.PatternSyntaxException;@@ -75,6 +76,7 @@ public class BlacklistCleaner_p {private static final int ERR_PATH_REGEX = 2;private static final int ERR_WILDCARD_BEGIN_OR_END = 3;private static final int ERR_HOST_WRONG_CHARS = 4;+ private static final int ERR_DOUBLE_OCCURANCE = 5;public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {serverObjects prop = new serverObjects();@@ -161,21 +163,31 @@ public class BlacklistCleaner_p {private static HashMap /* entry, error-code */ getIllegalEntries(String blacklistToUse, String[] supportedBlacklistTypes, plasmaURLPattern blEngine) {HashMap r = new HashMap();+ HashSet ok = new HashSet();ArrayList list = listManager.getListArray(new File(listManager.listsPath, blacklistToUse));Iterator it = list.iterator();String s, host, path;if (blEngine instanceof defaultURLPattern) {+ int slashPos;while (it.hasNext()) {- s = (String)it.next();-- if (s.indexOf("/") == -1) {+ s = ((String)it.next()).trim();++ // check for double-occurance+ if (ok.contains(s)) {+ r.put(s, new Integer(ERR_DOUBLE_OCCURANCE));+ continue;+ } else {+ ok.add(s);+ }++ if ((slashPos = s.indexOf("/")) == -1) {host = s;path = ".*";} else {- host = s.substring(0, s.indexOf("/"));- path = s.substring(s.indexOf("/") + 1);+ host = s.substring(0, slashPos);+ path = s.substring(slashPos + 1);}int i = host.indexOf("*");@@ -231,7 +243,7 @@ public class BlacklistCleaner_p {String s;for (int i=0; i<entries.length; i++) {s = entries[i];- if (list != null) list.remove(s);+ if (list != null) while (list.contains(s)) list.remove(s);// remove the entry from the running blacklist enginefor (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {