From 0bff9cea070ff8620d530e86331309c6cb80d1a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 8 Sep 2024 02:16:26 +0200 Subject: [PATCH] Continued: - check if instance[host] is at least set and a non-empty string --- fba/networks/misskey.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fba/networks/misskey.py b/fba/networks/misskey.py index 5d71e58..cf8849d 100644 --- a/fba/networks/misskey.py +++ b/fba/networks/misskey.py @@ -297,6 +297,17 @@ def fetch_blocks(domain: str) -> list: for instance in rows: # Is it there? logger.debug("instance[]='%s'", type(instance)) + if not isinstance(instance, dict): + logger.warning("instance[]='%s' is not of type 'dict' - SKIPPED!", type(instance)) + continue + elif not "host" in instance: + logger.warning("instance()=%d has no element 'host' - SKIPPED!", len(instance)) + continue + elif not isinstance(instance["host"], str): + logger.warning("instance[host][]='%s' is not of type 'str' - SKIPPED!", type(instance["host"])) + continue + + logger.debug("instance[host]='%s' - BEFORE!", instance["host"]) blocked = tidyup.domain(instance["host"]) if instance["host"] != "" else None logger.debug("blocked='%s' - AFTER!", blocked) -- 2.39.5