From ce7cc8d7deb5f8c986e21c8231e4afd4844ec7fb Mon Sep 17 00:00:00 2001 From: bashrc Date: Fri, 24 Apr 2026 12:12:25 +0100 Subject: [PATCH] Checking domains --- daemon_get.py | 5 ++--- daemon_get_masto_api.py | 2 +- daemon_get_nodeinfo.py | 5 ++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/daemon_get.py b/daemon_get.py index 7a21d4bdc..a208ea3c8 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -96,6 +96,7 @@ from flags import is_artist from flags import is_blog_post from timeFunctions import date_utcnow from timeFunctions import get_current_time_int +from utils import resembles_domain from utils import string_starts_with from utils import is_yggdrasil_address from utils import replace_strings @@ -6364,9 +6365,7 @@ def _security_txt(self, ua_str: str, calling_domain: str, # is this a real website making the call ? if not debug and not self.server.unit_test and referer_domain: # Does calling_domain look like a domain? - if ' ' in referer_domain or \ - ';' in referer_domain or \ - '.' not in referer_domain: + if not resembles_domain(referer_domain): print('security.txt ' + 'referer domain does not look like a domain ' + referer_domain) diff --git a/daemon_get_masto_api.py b/daemon_get_masto_api.py index c2a4f4086..59c269116 100644 --- a/daemon_get_masto_api.py +++ b/daemon_get_masto_api.py @@ -114,7 +114,7 @@ def _masto_api_v1(self, path: str, calling_domain: str, # is this a real website making the call ? if not debug and not unit_test and referer_domain: # Does calling_domain look like a domain? - if resembles_domain(referer_domain): + if not resembles_domain(referer_domain): print('mastodon api ' + 'referer does not look like a domain ' + referer_domain) diff --git a/daemon_get_nodeinfo.py b/daemon_get_nodeinfo.py index 296ca3181..f17f5b00a 100644 --- a/daemon_get_nodeinfo.py +++ b/daemon_get_nodeinfo.py @@ -13,6 +13,7 @@ from httpcodes import http_404 from httpcodes import http_503 from httpcodes import write2 from httpheaders import set_headers +from utils import resembles_domain from utils import string_starts_with from utils import convert_domains from utils import get_instance_url @@ -73,9 +74,7 @@ def get_nodeinfo(self, ua_str: str, calling_domain: str, # is this a real website making the call ? if not debug and not unit_test and referer_domain: # Does calling_domain look like a domain? - if ' ' in referer_domain or \ - ';' in referer_domain or \ - '.' not in referer_domain: + if not resembles_domain(referer_domain): print('nodeinfo referer domain does not look like a domain ' + referer_domain) http_400(self)