Checking domains

main
bashrc 2026-04-24 12:12:25 +01:00
parent 15d0c1defa
commit ce7cc8d7de
3 changed files with 5 additions and 7 deletions

View File

@ -96,6 +96,7 @@ from flags import is_artist
from flags import is_blog_post from flags import is_blog_post
from timeFunctions import date_utcnow from timeFunctions import date_utcnow
from timeFunctions import get_current_time_int from timeFunctions import get_current_time_int
from utils import resembles_domain
from utils import string_starts_with from utils import string_starts_with
from utils import is_yggdrasil_address from utils import is_yggdrasil_address
from utils import replace_strings 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 ? # is this a real website making the call ?
if not debug and not self.server.unit_test and referer_domain: if not debug and not self.server.unit_test and referer_domain:
# Does calling_domain look like a domain? # Does calling_domain look like a domain?
if ' ' in referer_domain or \ if not resembles_domain(referer_domain):
';' in referer_domain or \
'.' not in referer_domain:
print('security.txt ' + print('security.txt ' +
'referer domain does not look like a domain ' + 'referer domain does not look like a domain ' +
referer_domain) referer_domain)

View File

@ -114,7 +114,7 @@ def _masto_api_v1(self, path: str, calling_domain: str,
# is this a real website making the call ? # is this a real website making the call ?
if not debug and not unit_test and referer_domain: if not debug and not unit_test and referer_domain:
# Does calling_domain look like a domain? # Does calling_domain look like a domain?
if resembles_domain(referer_domain): if not resembles_domain(referer_domain):
print('mastodon api ' + print('mastodon api ' +
'referer does not look like a domain ' + 'referer does not look like a domain ' +
referer_domain) referer_domain)

View File

@ -13,6 +13,7 @@ from httpcodes import http_404
from httpcodes import http_503 from httpcodes import http_503
from httpcodes import write2 from httpcodes import write2
from httpheaders import set_headers from httpheaders import set_headers
from utils import resembles_domain
from utils import string_starts_with from utils import string_starts_with
from utils import convert_domains from utils import convert_domains
from utils import get_instance_url 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 ? # is this a real website making the call ?
if not debug and not unit_test and referer_domain: if not debug and not unit_test and referer_domain:
# Does calling_domain look like a domain? # Does calling_domain look like a domain?
if ' ' in referer_domain or \ if not resembles_domain(referer_domain):
';' in referer_domain or \
'.' not in referer_domain:
print('nodeinfo referer domain does not look like a domain ' + print('nodeinfo referer domain does not look like a domain ' +
referer_domain) referer_domain)
http_400(self) http_400(self)