mirror of https://gitlab.com/bashrc2/epicyon
Snake case
parent
0a1f09175f
commit
b63039ae47
|
@ -281,7 +281,7 @@ from utils import media_file_mime_type
|
||||||
from utils import getCSS
|
from utils import getCSS
|
||||||
from utils import first_paragraph_from_string
|
from utils import first_paragraph_from_string
|
||||||
from utils import clearFromPostCaches
|
from utils import clearFromPostCaches
|
||||||
from utils import containsInvalidChars
|
from utils import contains_invalid_chars
|
||||||
from utils import is_system_account
|
from utils import is_system_account
|
||||||
from utils import setConfigParam
|
from utils import setConfigParam
|
||||||
from utils import get_config_param
|
from utils import get_config_param
|
||||||
|
@ -18224,7 +18224,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
return
|
return
|
||||||
|
|
||||||
if containsInvalidChars(messageBytes.decode("utf-8")):
|
if contains_invalid_chars(messageBytes.decode("utf-8")):
|
||||||
self._400()
|
self._400()
|
||||||
self.server.POSTbusy = False
|
self.server.POSTbusy = False
|
||||||
return
|
return
|
||||||
|
|
|
@ -28,7 +28,7 @@ from utils import locate_post
|
||||||
from utils import load_json
|
from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import is_suspended
|
from utils import is_suspended
|
||||||
from utils import containsInvalidChars
|
from utils import contains_invalid_chars
|
||||||
from utils import remove_html
|
from utils import remove_html
|
||||||
from utils import is_account_dir
|
from utils import is_account_dir
|
||||||
from utils import acct_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)
|
result = session.get(url, headers=sessionHeaders, params=sessionParams)
|
||||||
if result:
|
if result:
|
||||||
if int(len(result.text) / 1024) < maxFeedSizeKb and \
|
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,
|
return _xmlStrToDict(base_dir, domain, result.text,
|
||||||
moderated, mirrored,
|
moderated, mirrored,
|
||||||
maxPostsPerSource,
|
maxPostsPerSource,
|
||||||
|
|
|
@ -39,7 +39,7 @@ from roles import setRolesFromList
|
||||||
from roles import getActorRolesList
|
from roles import getActorRolesList
|
||||||
from media import processMetaData
|
from media import processMetaData
|
||||||
from utils import remove_html
|
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 replace_users_with_at
|
||||||
from utils import remove_line_endings
|
from utils import remove_line_endings
|
||||||
from utils import remove_domain_port
|
from utils import remove_domain_port
|
||||||
|
@ -1725,7 +1725,7 @@ def validSendingActor(session, base_dir: str,
|
||||||
|
|
||||||
if actor_json.get('name'):
|
if actor_json.get('name'):
|
||||||
bioStr += ' ' + remove_html(actor_json['name'])
|
bioStr += ' ' + remove_html(actor_json['name'])
|
||||||
if containsInvalidChars(bioStr):
|
if contains_invalid_chars(bioStr):
|
||||||
print('REJECT: post actor bio contains invalid characters')
|
print('REJECT: post actor bio contains invalid characters')
|
||||||
return False
|
return False
|
||||||
if isFilteredBio(base_dir, nickname, domain, bioStr):
|
if isFilteredBio(base_dir, nickname, domain, bioStr):
|
||||||
|
|
|
@ -30,7 +30,7 @@ from utils import load_json
|
||||||
from utils import save_json
|
from utils import save_json
|
||||||
from utils import remove_post_from_cache
|
from utils import remove_post_from_cache
|
||||||
from utils import get_cached_post_filename
|
from utils import get_cached_post_filename
|
||||||
from utils import containsInvalidChars
|
from utils import contains_invalid_chars
|
||||||
from posts import sendSignedJson
|
from posts import sendSignedJson
|
||||||
from session import postJson
|
from session import postJson
|
||||||
from webfinger import webfingerHandle
|
from webfinger import webfingerHandle
|
||||||
|
@ -55,7 +55,7 @@ def validEmojiContent(emojiContent: str) -> bool:
|
||||||
return False
|
return False
|
||||||
if len(emojiRegex.findall(emojiContent)) == 0:
|
if len(emojiRegex.findall(emojiContent)) == 0:
|
||||||
return False
|
return False
|
||||||
if containsInvalidChars(emojiContent):
|
if contains_invalid_chars(emojiContent):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
21
utils.py
21
utils.py
|
@ -743,32 +743,33 @@ def evil_incarnate() -> []:
|
||||||
|
|
||||||
|
|
||||||
def is_evil(domain: str) -> bool:
|
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):
|
if not isinstance(domain, str):
|
||||||
print('WARN: Malformed domain ' + str(domain))
|
print('WARN: Malformed domain ' + str(domain))
|
||||||
return True
|
return True
|
||||||
# if a domain contains any of these strings then it is
|
# if a domain contains any of these strings then it is
|
||||||
# declaring itself to be hostile
|
# declaring itself to be hostile
|
||||||
evilEmporium = (
|
evil_emporium = (
|
||||||
'nazi', 'extremis', 'extreemis', 'gendercritic',
|
'nazi', 'extremis', 'extreemis', 'gendercritic',
|
||||||
'kiwifarm', 'illegal', 'raplst', 'rapist',
|
'kiwifarm', 'illegal', 'raplst', 'rapist',
|
||||||
'antivax', 'plandemic'
|
'antivax', 'plandemic'
|
||||||
)
|
)
|
||||||
for hostileStr in evilEmporium:
|
for hostile_str in evil_emporium:
|
||||||
if hostileStr in domain:
|
if hostile_str in domain:
|
||||||
return True
|
return True
|
||||||
evilDomains = evil_incarnate()
|
evil_domains = evil_incarnate()
|
||||||
for concentratedEvil in evilDomains:
|
for concentrated_evil in evil_domains:
|
||||||
if domain.endswith(concentratedEvil):
|
if domain.endswith(concentrated_evil):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def containsInvalidChars(jsonStr: str) -> bool:
|
def contains_invalid_chars(json_str: str) -> bool:
|
||||||
"""Does the given json string contain invalid characters?
|
"""Does the given json string contain invalid characters?
|
||||||
"""
|
"""
|
||||||
for isInvalid in INVALID_CHARACTERS:
|
for is_invalid in INVALID_CHARACTERS:
|
||||||
if isInvalid in jsonStr:
|
if is_invalid in json_str:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue