Skip to content
Permalink
Browse files

Fixed remaining blacklist entries improper decoding of '+' character

In the blacklist cleaner and import/export administration pages.
  • Loading branch information...
luccioman committed Oct 8, 2018
1 parent 61c337f commit 753bda1409e57e345bf0e16516db9d835e6ebece
Showing with 14 additions and 17 deletions.
  1. +10 −13 htroot/BlacklistCleaner_p.java
  2. +4 −4 htroot/sharedBlacklist_p.java
@@ -45,6 +45,7 @@
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.ListManager;
import net.yacy.document.parser.html.CharacterCoding;
import net.yacy.kelondro.util.FileUtils;
import net.yacy.repository.Blacklist;
import net.yacy.repository.BlacklistHostAndPath;
@@ -123,9 +124,7 @@ public static serverObjects respond(
}

// list illegal entries
final Map<String, BlacklistError> illegalEntries = getIllegalEntries(
blacklistToUse, Switchboard.urlBlacklist,
allowRegex);
final Map<String, BlacklistError> illegalEntries = getIllegalEntries(blacklistToUse, allowRegex);
prop.put(RESULTS + "blList", blacklistToUse);
prop.put(RESULTS + "entries", illegalEntries.size());
prop.putHTML(RESULTS + "blEngine", Blacklist.getEngineInfo());
@@ -141,8 +140,9 @@ public static serverObjects respond(
key = entry.getKey();
prop.put(RESULTS + DISABLED + ENTRIES + i + "_error",
entry.getValue().getLong());
prop.putHTML(RESULTS + DISABLED + ENTRIES + i
+ "_entry", key);
/* 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(RESULTS + DISABLED + ENTRIES + i
+ "_entry", CharacterCoding.unicode2html(key, true));
i++;
}
}
@@ -284,8 +284,6 @@ private static void putBlacklists(final serverObjects prop,
*
* @param blacklistToUse
* The blacklist to be checked.
* @param blEngine
* The blacklist engine which is used to check
* @param allowRegex
* Set to true to allow regular expressions in host part of
* blacklist entry.
@@ -294,18 +292,17 @@ private static void putBlacklists(final serverObjects prop,
* error code as value.
*/
private static Map<String, BlacklistError> getIllegalEntries(
final String blacklistToUse, final Blacklist blEngine,
final String blacklistToUse,
final boolean allowRegex) {
final Map<String, BlacklistError> illegalEntries = new HashMap<String, BlacklistError>();
final Set<String> legalEntries = new HashSet<String>();
final Map<String, BlacklistError> illegalEntries = new HashMap<>();
final Set<String> legalEntries = new HashSet<>();

final List<String> list = FileUtils.getListArray(new File(
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));

BlacklistError err = BlacklistError.NO_ERROR;

BlacklistError err;
for (String element : list) {
element = element.trim();

@@ -285,9 +285,9 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
while (otherBlacklist.hasNext()) {
final String tmp = otherBlacklist.next();
if( !Blacklist.contains(tmp) && (!tmp.equals("")) ){
//newBlacklist.add(tmp);
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);
count++;
}
@@ -310,9 +310,9 @@ public static serverObjects respond(@SuppressWarnings("unused") final RequestHea
for (final String element : sortedlist) {
final String tmp = element;
if(!tmp.equals("")){
//newBlacklist.add(tmp);
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);
count++;
}

0 comments on commit 753bda1

Please sign in to comment.
You can’t perform that action at this time.