From cf0d1c9f86fb8094fd3deb9edb19505307edc8d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 30 Sep 2023 23:54:51 +0200 Subject: [PATCH] Continued: - added some more checks to avoid exceptions --- fba/networks/misskey.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index b21db1e..7217b86 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -199,10 +199,21 @@ def fetch_blocks(domain: str) -> list: for instance in rows: # Is it there? logger.debug("instance[]='%s'", type(instance)) + if "host" not in instance: + logger.warning("instance(%d)='%s' has no key 'host' - SKIPPED!", len(instance), instance) + continue + elif instance["host"] is None or instance["host"] == "": + logger.debug("instance[host]='%s' is None or empty - SKIPPED!", instance["host"]) + continue + + logger.debug("instance[host]='%s' - BEFORE!", instance["host"]) blocked = tidyup.domain(instance["host"]) - logger.debug("blocked='%s'", blocked) - if not domain_helper.is_wanted(blocked): + logger.debug("blocked[%s]='%s' - AFTER!", type(blocked), blocked) + if blocked is None or blocked == "": + logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"]) + continue + elif not domain_helper.is_wanted(blocked): logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked) continue elif "isSuspended" in instance and instance["isSuspended"] and not dict_helper.has_key(blocklist, "blocked", blocked): -- 2.39.5