Fixed remaining blacklist entries improper decoding of '+' character

In the blacklist cleaner and import/export administration pages.
pull/250/head
luccioman 6 years ago
parent 61c337f29a
commit 753bda1409

@ -45,6 +45,7 @@ import net.yacy.cora.document.id.Punycode.PunycodeException;
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.ListManager; import net.yacy.data.ListManager;
import net.yacy.document.parser.html.CharacterCoding;
import net.yacy.kelondro.util.FileUtils; import net.yacy.kelondro.util.FileUtils;
import net.yacy.repository.Blacklist; import net.yacy.repository.Blacklist;
import net.yacy.repository.BlacklistHostAndPath; import net.yacy.repository.BlacklistHostAndPath;
@ -123,9 +124,7 @@ public class BlacklistCleaner_p {
} }
// list illegal entries // list illegal entries
final Map<String, BlacklistError> illegalEntries = getIllegalEntries( final Map<String, BlacklistError> illegalEntries = getIllegalEntries(blacklistToUse, allowRegex);
blacklistToUse, Switchboard.urlBlacklist,
allowRegex);
prop.put(RESULTS + "blList", blacklistToUse); prop.put(RESULTS + "blList", blacklistToUse);
prop.put(RESULTS + "entries", illegalEntries.size()); prop.put(RESULTS + "entries", illegalEntries.size());
prop.putHTML(RESULTS + "blEngine", Blacklist.getEngineInfo()); prop.putHTML(RESULTS + "blEngine", Blacklist.getEngineInfo());
@ -141,8 +140,9 @@ public class BlacklistCleaner_p {
key = entry.getKey(); key = entry.getKey();
prop.put(RESULTS + DISABLED + ENTRIES + i + "_error", prop.put(RESULTS + DISABLED + ENTRIES + i + "_error",
entry.getValue().getLong()); entry.getValue().getLong());
prop.putHTML(RESULTS + DISABLED + ENTRIES + i /* We do not use here putHTML as we don't want '+' characters to be decoded as spaces by application/x-www-form-urlencoded encoding */
+ "_entry", key); prop.put(RESULTS + DISABLED + ENTRIES + i
+ "_entry", CharacterCoding.unicode2html(key, true));
i++; i++;
} }
} }
@ -284,8 +284,6 @@ public class BlacklistCleaner_p {
* *
* @param blacklistToUse * @param blacklistToUse
* The blacklist to be checked. * The blacklist to be checked.
* @param blEngine
* The blacklist engine which is used to check
* @param allowRegex * @param allowRegex
* Set to true to allow regular expressions in host part of * Set to true to allow regular expressions in host part of
* blacklist entry. * blacklist entry.
@ -294,18 +292,17 @@ public class BlacklistCleaner_p {
* error code as value. * error code as value.
*/ */
private static Map<String, BlacklistError> getIllegalEntries( private static Map<String, BlacklistError> getIllegalEntries(
final String blacklistToUse, final Blacklist blEngine, final String blacklistToUse,
final boolean allowRegex) { final boolean allowRegex) {
final Map<String, BlacklistError> illegalEntries = new HashMap<String, BlacklistError>(); final Map<String, BlacklistError> illegalEntries = new HashMap<>();
final Set<String> legalEntries = new HashSet<String>(); final Set<String> legalEntries = new HashSet<>();
final List<String> list = FileUtils.getListArray(new File( final List<String> list = FileUtils.getListArray(new File(
ListManager.listsPath, blacklistToUse)); ListManager.listsPath, blacklistToUse));
final Map<String, String> properties = new HashMap<String, String>(); final Map<String, String> properties = new HashMap<>();
properties.put("allowRegex", String.valueOf(allowRegex)); properties.put("allowRegex", String.valueOf(allowRegex));
BlacklistError err = BlacklistError.NO_ERROR; BlacklistError err;
for (String element : list) { for (String element : list) {
element = element.trim(); element = element.trim();

@ -285,9 +285,9 @@ public class sharedBlacklist_p {
while (otherBlacklist.hasNext()) { while (otherBlacklist.hasNext()) {
final String tmp = otherBlacklist.next(); final String tmp = otherBlacklist.next();
if( !Blacklist.contains(tmp) && (!tmp.equals("")) ){ if( !Blacklist.contains(tmp) && (!tmp.equals("")) ){
//newBlacklist.add(tmp);
prop.put("page_urllist_" + count + "_dark", count % 2 == 0 ? "0" : "1"); prop.put("page_urllist_" + count + "_dark", count % 2 == 0 ? "0" : "1");
prop.putHTML("page_urllist_" + count + "_url", tmp); /* We do not use here putHTML as we don't want '+' characters to be decoded as spaces by application/x-www-form-urlencoded encoding */
prop.put("page_urllist_" + count + "_url", CharacterCoding.unicode2html(tmp, true));
prop.put("page_urllist_" + count + "_count", count); prop.put("page_urllist_" + count + "_count", count);
count++; count++;
} }
@ -310,9 +310,9 @@ public class sharedBlacklist_p {
for (final String element : sortedlist) { for (final String element : sortedlist) {
final String tmp = element; final String tmp = element;
if(!tmp.equals("")){ if(!tmp.equals("")){
//newBlacklist.add(tmp);
prop.put("page_urllist_" + count + "_dark", count % 2 == 0 ? "0" : "1"); prop.put("page_urllist_" + count + "_dark", count % 2 == 0 ? "0" : "1");
prop.putHTML("page_urllist_" + count + "_url", tmp); /* We do not use here putHTML as we don't want '+' characters to be decoded as spaces by application/x-www-form-urlencoded encoding */
prop.put("page_urllist_" + count + "_url", CharacterCoding.unicode2html(tmp, true));
prop.put("page_urllist_" + count + "_count", count); prop.put("page_urllist_" + count + "_count", count);
count++; count++;
} }

Loading…
Cancel
Save