]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 15 Jun 2024 13:11:40 +0000 (15:11 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 15 Jun 2024 13:11:40 +0000 (15:11 +0200)
- if the found digest isn't valid, then set it to None
- ignore (not skip) any invalid digests

fba/networks/mastodon.py

index 704d4f13847c42064260612c48828804075076d6..b379ae078651ec83204f71b4ae807c175434e4b1 100644 (file)
@@ -121,14 +121,22 @@ def fetch_blocks_from_about(domain: str) -> dict:
             # replaced find_next_siblings with find_all_next to account for instances that e.g. hide lists in dropdown menu
             for line in header.find_all_next("table")[0].find_all("tr")[1:]:
                 domain = line.find("span").text
-                digest = line.find("span")["title"][9:]
                 reason = line.find_all("td")[1].text
 
                 logger.debug("domain='%s',reason='%s' - BEFORE!", domain, reason)
                 domain = tidyup.domain(domain) if domain != "" else None
                 reason = tidyup.reason(reason) if reason != "" else None
-
                 logger.debug("domain='%s',reason='%s' - AFTER!", domain, reason)
+
+                digest = line.find("span")["title"][9:]
+
+                logger.debug("digest='%s' - BEFORE!", digest)
+                if not validators.hashes.sha256(digest):
+                    logger.warning("domain='%s' has invalid digest='%s' - Setting to None ...", domain, digest)
+                    digest = None
+                logger.debug("digest='%s' - AFTER!", digest)
+
+                logger.debug("domain[]='%s'", type(domain))
                 if domain in [None, ""]:
                     logger.warning("domain='%s' is empty,line='%s' - SKIPPED!", domain, line)
                     continue
@@ -182,7 +190,7 @@ def fetch_blocks(domain: str) -> list:
                 elif block_level in ["accept", "accepted"]:
                     logger.debug("block[domain]='%s' has unwanted severity level '%s' - SKIPPED!", block["domain"], block_level)
                     continue
-                elif "digest" in block and not validators.hashes.sha256(block["digest"]):
+                elif "digest" in block and not block["digest"] is None and not validators.hashes.sha256(block["digest"]):
                     logger.warning("block[domain]='%s' has invalid block[digest]='%s' - SKIPPED!", block["domain"], block["digest"])
                     continue