diff --git a/blocking.py b/blocking.py index f9d3a8807..0b745cea3 100644 --- a/blocking.py +++ b/blocking.py @@ -12,6 +12,7 @@ import json import time from session import get_json_valid from session import create_session +from utils import string_contains from utils import date_from_string_format from utils import date_utcnow from utils import remove_eol @@ -1998,10 +1999,7 @@ def save_block_federated_endpoints(base_dir: str, if not endpoint: continue if '.' not in endpoint or \ - ' ' in endpoint or \ - '<' in endpoint or \ - ',' in endpoint or \ - ';' in endpoint: + string_contains(endpoint, (' ', '<', ',', ';')): continue if endpoint.startswith('@'): endpoint = endpoint[1:] diff --git a/content.py b/content.py index befb8b893..38912abfd 100644 --- a/content.py +++ b/content.py @@ -15,6 +15,7 @@ import email.parser import urllib.parse from shutil import copyfile from dateutil.parser import parse +from utils import string_contains from utils import string_ends_with from utils import is_account_dir from utils import get_url_from_post @@ -263,9 +264,7 @@ def dangerous_css(filename: str, allow_local_network_access: bool) -> bool: if ctr > 0: if ')' in url_str: url_str = url_str.split(')')[0] - if 'http' in url_str or \ - 'ipfs' in url_str or \ - 'ipns' in url_str: + if string_contains(url_str, ('http', 'ipfs', 'ipns')): print('ERROR: non-local web link in CSS ' + filename) return True diff --git a/daemon.py b/daemon.py index 44f40fec2..60407fa6e 100644 --- a/daemon.py +++ b/daemon.py @@ -50,6 +50,7 @@ from shares import expire_shares from categories import load_city_hashtags from categories import update_hashtag_categories from languages import load_default_post_languages +from utils import string_contains from utils import check_bad_path from utils import acct_handle_dir from utils import load_reverse_timeline @@ -310,9 +311,9 @@ class PubServer(BaseHTTPRequestHandler): file_length = -1 last_modified_time_str = None - if '/media/' in self.path or \ - '/accounts/avatars/' in self.path or \ - '/accounts/headers/' in self.path: + if string_contains(self.path, + ('/media/', '/accounts/avatars/', + '/accounts/headers/')): if is_image_file(self.path) or \ path_is_video(self.path) or \ path_is_audio(self.path):