automatic generation of blacklist pattern, see

http://forum.yacy-websuche.de/viewtopic.php?f=5&t=2685&p=25305#p25305
pull/1/head
Michael Peter Christen 13 years ago
parent 7b5b9baee0
commit f31ad84d98

@ -636,6 +636,14 @@ public class Blacklist_p {
newEntry = newEntry.substring(8);
}
if (newEntry.indexOf("*") < 0) {
// user did not use any wild cards and just submitted a word
addBlacklistEntry0(listsPath, blacklistToUse, ".*" + newEntry + ".*/.*", supportedBlacklistTypes);
addBlacklistEntry0(listsPath, blacklistToUse, ".*.*/.*" + newEntry + ".*", supportedBlacklistTypes);
} else {
int pos = newEntry.indexOf('/',0);
if (pos < 0) {
// add default empty path pattern
@ -643,6 +651,16 @@ public class Blacklist_p {
newEntry = newEntry + "/.*";
}
addBlacklistEntry0(listsPath, blacklistToUse, newEntry, supportedBlacklistTypes);
}
}
private static void addBlacklistEntry0(
final File listsPath,
final String blacklistToUse,
String newEntry,
final String[] supportedBlacklistTypes) {
if (!Blacklist.blacklistFileContains(listsPath, blacklistToUse, newEntry)) {
// append the line to the file
PrintWriter pw = null;
@ -664,6 +682,7 @@ public class Blacklist_p {
}
// add to blacklist
int pos = newEntry.indexOf('/',0);
for (final String supportedBlacklistType : supportedBlacklistTypes) {
if (ListManager.listSetContains(supportedBlacklistType + ".BlackLists", blacklistToUse)) {
Switchboard.urlBlacklist.add(supportedBlacklistType, newEntry.substring(0, pos), newEntry.substring(pos + 1));

Loading…
Cancel
Save