Skip to content

Commit

Permalink
- remove double entries in blacklist as well
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3390 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
karlchenofhell committed Feb 23, 2007
1 parent bf7a691 commit 3d6ab19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 7 additions & 1 deletion htroot/BlacklistCleaner_p.html
Expand Up @@ -36,7 +36,13 @@ <h2>Blacklist Cleaner</h2>
#{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>
Expand Down
24 changes: 18 additions & 6 deletions htroot/BlacklistCleaner_p.java
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -161,21 +163,31 @@ private static String[] getByPrefix(serverObjects post, String prefix) {

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("*");
Expand Down Expand Up @@ -231,7 +243,7 @@ private static int removeEntries(String blacklistToUse, String[] supportedBlackl
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 engine
for (int blTypes=0; blTypes < supportedBlacklistTypes.length; blTypes++) {
Expand Down

0 comments on commit 3d6ab19

Please sign in to comment.