From 295618ea79b35b321817ca807fad609461d69b56 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 25 Jun 2023 04:40:14 +0200 Subject: [PATCH] Continued: - also don't allow/ignore URLs with /tag/ in it - ops, hash wasn't provided to instances.deobfuscate() --- fba/commands.py | 2 +- fba/helpers/tidyup.py | 2 ++ fba/http/federation.py | 3 +++ fba/models/instances.py | 2 ++ fba/utils.py | 6 ++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fba/commands.py b/fba/commands.py index a4bccbc..be890fe 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -298,7 +298,7 @@ def fetch_blocks(args: argparse.Namespace) -> int: instances.set_has_obfuscation(blocker, True) # Some obscure them with question marks, not sure if that's dependent on version or not - row = instances.deobfuscate("?", block["blocked"] if "hash" in block else None) + row = instances.deobfuscate("?", block["blocked"], block["hash"] if "hash" in block else None) logger.debug("row[]='%s'", type(row)) if row is None: diff --git a/fba/helpers/tidyup.py b/fba/helpers/tidyup.py index 5611e65..ef027af 100644 --- a/fba/helpers/tidyup.py +++ b/fba/helpers/tidyup.py @@ -64,6 +64,8 @@ def domain(string: str) -> str: string = string.split("/profile/")[0] elif string.find("/users/"): string = string.split("/users/")[0] + elif string.find("/tag/"): + string = string.split("/tag/")[0] logger.debug("string='%s' - EXIT!", string) return string diff --git a/fba/http/federation.py b/fba/http/federation.py index 0dcf180..c3ad8fb 100644 --- a/fba/http/federation.py +++ b/fba/http/federation.py @@ -124,6 +124,9 @@ def fetch_instances(domain: str, origin: str, software: str, command: str, path: elif instance.find("/profile/") > 0 or instance.find("/users/") > 0 or (instances.is_registered(instance.split("/")[0]) and instance.find("/c/") > 0): logger.debug("instance='%s' is a link to a single user profile - SKIPPED!", instance) continue + elif instance.find("/tag/") > 0: + logger.debug("instance='%s' is a link to a tag - SKIPPED!", instance) + continue elif not instances.is_registered(instance): logger.debug("Adding new instance='%s',domain='%s',command='%s'", instance, domain, command) instances.add(instance, domain, command) diff --git a/fba/models/instances.py b/fba/models/instances.py index 8746d23..458196c 100644 --- a/fba/models/instances.py +++ b/fba/models/instances.py @@ -171,6 +171,8 @@ def add(domain: str, origin: str, command: str, path: str = None, software: str raise Exception(f"domain='{domain}' is blacklisted, but method invoked") elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (is_registered(domain.split("/")[0]) and domain.find("/c/") > 0): raise Exception(f"domain='{domain}' is a single user") + elif domain.find("/tag/") > 0: + raise Exception(f"domain='{domain}' is a tag") if software is None: try: diff --git a/fba/utils.py b/fba/utils.py index 4cc5f18..d7909b5 100644 --- a/fba/utils.py +++ b/fba/utils.py @@ -194,6 +194,12 @@ def is_domain_wanted(domain: str) -> bool: elif blacklist.is_blacklisted(domain): logger.debug("domain='%s' is blacklisted - settings False ...", domain) wanted = False + elif domain.find("/profile/") > 0 or domain.find("/users/") > 0 or (instances.is_registered(domain.split("/")[0]) and domain.find("/c/") > 0): + loger.debug("domain='%s' is a single user", domain) + wanted = False + elif domain.find("/tag/") > 0: + logger.debug("domain='%s' is a tag", domain) + wanted = False logger.debug("wanted='%s' - EXIT!", wanted) return wanted -- 2.39.5