This commit is contained in:
Aevann1 2021-11-18 22:50:03 +02:00
parent 301db1841e
commit bc316cb7bc
19 changed files with 100 additions and 23 deletions

View file

@ -164,6 +164,12 @@ def api_comment(v):
marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body))
if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403
if v.longpost:
if time.time() > v.longpost:
v.longpost = None
g.db.add(v)
elif len(body) < 280: return {"error":"You have to type more than 280 characters!"}, 403
if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
@ -188,6 +194,8 @@ def api_comment(v):
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403
if v.longpost and len(body) < 280: return {"error":"You have to type more than 280 characters!"}, 403
bans = filter_comment_html(body_html)
if bans:
@ -609,6 +617,12 @@ def edit_comment(cid, v):
marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body))
if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403
if v.longpost:
if time.time() > v.longpost:
v.longpost = None
g.db.add(v)
elif len(body) < 280: return {"error":"You have to type more than 280 characters!"}, 403
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE):
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})')
body_md = CustomRenderer().render(mistletoe.Document(body))
@ -616,6 +630,8 @@ def edit_comment(cid, v):
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 403
if v.longpost and len(body) < 280: return {"error":"You have to type more than 280 characters!"}, 403
bans = filter_comment_html(body_html)
if bans: