From 3a5f82d31c552dc3e979566d2d7b422525466110 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 1 Jul 2023 03:18:39 +0200 Subject: [PATCH] Continued: - skip empty domains after tidyup.domain() --- fba/networks/lemmy.py | 7 +++++-- fba/networks/pleroma.py | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 946d0eb..88e18e0 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -174,11 +174,14 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: blocked = tidyup.domain(tag.contents[0]) logger.debug("blocked='%s'", blocked) - if not utils.is_domain_wanted(blocked): + if blocked == "": + logger.warning("blocked='%s' is empty after tidyup.domain() - SKIPPED!", tag.contents[0]) + continue + elif not utils.is_domain_wanted(blocked): logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) continue - logger.debug("Appending blocker='%s',blocked='%s',block_level='reject'", domain, blocked) + logger.debug("Appending blocker='%s',blocked='%s',block_level='reject' ...", domain, blocked) blocklist.append({ "blocker" : domain, "blocked" : blocked, diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index 49ec65b..a701fdc 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -103,7 +103,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: logger.debug("blocked='%s' - AFTER!", blocked) if blocked == "": - logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) + logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s' - SKIPPED!", domain, block_level) continue elif not utils.is_domain_wanted(blocked): logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) @@ -238,7 +238,7 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: logger.warning("Cannot find blocked='%s' in rows()=%d,domain='%s' - BREAK!", blocked, len(rows), domain) break - reason = rows[blocked]["reason"] + reason = tidyup.reason(rows[blocked]["reason"]) logger.debug("reason='%s'", reason) if blocked == "": @@ -283,16 +283,17 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: reason = tidyup.reason(record["reason"]) logger.debug("blocked='%s',reason='%s' - AFTER!", blocked, reason) - if blocked == "": - logger.warning("blocked is empty after tidyup.domain(): domain='%s',block_level='%s'", domain, block_level) - continue - elif not utils.is_domain_wanted(blocked): + if not utils.is_domain_wanted(blocked): logger.warning("blocked='%s' is not wanted - SKIPPED!", blocked) continue logger.debug("Invoking utils.deobfuscate_domain(%s, %s) ...", blocked, domain) blocked = utils.deobfuscate_domain(blocked, domain) + logger.debug("blocked='%s' - DEOBFUSCATED!", blocked) + if not utils.is_domain_wanted(blocked): + logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) + continue logger.debug("Appending blocker='%s',blocked='%s',reason='%s',block_level='%s' ...",domain, blocked, reason, block_level) blockdict.append({ -- 2.39.5