diff --git a/daemon.py b/daemon.py index 9d5f2960e..b27470cf4 100644 --- a/daemon.py +++ b/daemon.py @@ -281,7 +281,7 @@ from utils import media_file_mime_type from utils import getCSS from utils import first_paragraph_from_string from utils import clearFromPostCaches -from utils import containsInvalidChars +from utils import contains_invalid_chars from utils import is_system_account from utils import setConfigParam from utils import get_config_param @@ -18224,7 +18224,7 @@ class PubServer(BaseHTTPRequestHandler): self.server.POSTbusy = False return - if containsInvalidChars(messageBytes.decode("utf-8")): + if contains_invalid_chars(messageBytes.decode("utf-8")): self._400() self.server.POSTbusy = False return diff --git a/newswire.py b/newswire.py index 6fa0ddd6a..94c6d19d9 100644 --- a/newswire.py +++ b/newswire.py @@ -28,7 +28,7 @@ from utils import locate_post from utils import load_json from utils import save_json from utils import is_suspended -from utils import containsInvalidChars +from utils import contains_invalid_chars from utils import remove_html from utils import is_account_dir from utils import acct_dir @@ -891,7 +891,7 @@ def getRSS(base_dir: str, domain: str, session, url: str, result = session.get(url, headers=sessionHeaders, params=sessionParams) if result: if int(len(result.text) / 1024) < maxFeedSizeKb and \ - not containsInvalidChars(result.text): + not contains_invalid_chars(result.text): return _xmlStrToDict(base_dir, domain, result.text, moderated, mirrored, maxPostsPerSource, diff --git a/person.py b/person.py index 5e84e294a..7b98b5792 100644 --- a/person.py +++ b/person.py @@ -39,7 +39,7 @@ from roles import setRolesFromList from roles import getActorRolesList from media import processMetaData from utils import remove_html -from utils import containsInvalidChars +from utils import contains_invalid_chars from utils import replace_users_with_at from utils import remove_line_endings from utils import remove_domain_port @@ -1725,7 +1725,7 @@ def validSendingActor(session, base_dir: str, if actor_json.get('name'): bioStr += ' ' + remove_html(actor_json['name']) - if containsInvalidChars(bioStr): + if contains_invalid_chars(bioStr): print('REJECT: post actor bio contains invalid characters') return False if isFilteredBio(base_dir, nickname, domain, bioStr): diff --git a/reaction.py b/reaction.py index 2888ccaf4..a133c691e 100644 --- a/reaction.py +++ b/reaction.py @@ -30,7 +30,7 @@ from utils import load_json from utils import save_json from utils import remove_post_from_cache from utils import get_cached_post_filename -from utils import containsInvalidChars +from utils import contains_invalid_chars from posts import sendSignedJson from session import postJson from webfinger import webfingerHandle @@ -55,7 +55,7 @@ def validEmojiContent(emojiContent: str) -> bool: return False if len(emojiRegex.findall(emojiContent)) == 0: return False - if containsInvalidChars(emojiContent): + if contains_invalid_chars(emojiContent): return False return True diff --git a/utils.py b/utils.py index 7b41232d9..0ce42dca8 100644 --- a/utils.py +++ b/utils.py @@ -743,32 +743,33 @@ def evil_incarnate() -> []: def is_evil(domain: str) -> bool: - # https://www.youtube.com/watch?v=5qw1hcevmdU + """ https://www.youtube.com/watch?v=5qw1hcevmdU + """ if not isinstance(domain, str): print('WARN: Malformed domain ' + str(domain)) return True # if a domain contains any of these strings then it is # declaring itself to be hostile - evilEmporium = ( + evil_emporium = ( 'nazi', 'extremis', 'extreemis', 'gendercritic', 'kiwifarm', 'illegal', 'raplst', 'rapist', 'antivax', 'plandemic' ) - for hostileStr in evilEmporium: - if hostileStr in domain: + for hostile_str in evil_emporium: + if hostile_str in domain: return True - evilDomains = evil_incarnate() - for concentratedEvil in evilDomains: - if domain.endswith(concentratedEvil): + evil_domains = evil_incarnate() + for concentrated_evil in evil_domains: + if domain.endswith(concentrated_evil): return True return False -def containsInvalidChars(jsonStr: str) -> bool: +def contains_invalid_chars(json_str: str) -> bool: """Does the given json string contain invalid characters? """ - for isInvalid in INVALID_CHARACTERS: - if isInvalid in jsonStr: + for is_invalid in INVALID_CHARACTERS: + if is_invalid in json_str: return True return False