This commit is contained in:
Aevann1 2021-11-24 00:36:38 +02:00
parent 16a3dd95b8
commit 2e39f547fa
20 changed files with 285 additions and 171 deletions

View file

@ -169,6 +169,11 @@ def api_comment(v):
v.longpost = None
g.db.add(v)
elif len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
elif v.bird:
if time.time() > v.bird:
v.bird = None
g.db.add(v)
elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403
if not body and not request.files.get('file'): return {"error":"You need to actually write something!"}, 400
@ -194,7 +199,10 @@ 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 or ' [](' in body or body.startswith('[](')): return {"error":"You have to type more than 280 characters!"}, 403
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
elif v.bird:
if len(body) > 140 : return {"error":"You have to type less than 140 characters!"}, 403
bans = filter_comment_html(body_html)
@ -627,6 +635,11 @@ def edit_comment(cid, v):
v.longpost = None
g.db.add(v)
elif len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
elif v.bird:
if time.time() > v.bird:
v.bird = None
g.db.add(v)
elif len(body) > 140: return {"error":"You have to type less than 140 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)})')
@ -635,7 +648,10 @@ 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 or ' [](' in body or body.startswith('[](')): return {"error":"You have to type more than 280 characters!"}, 403
if v.longpost:
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403
elif v.bird:
if len(body) > 140 : return {"error":"You have to type less than 140 characters!"}, 403
bans = filter_comment_html(body_html)