forked from MarseyWorld/MarseyWorld
fixed king
parent
af801c395a
commit
acd3843632
|
@ -679,7 +679,7 @@ imgur_regex = re.compile('(https://i\.imgur\.com/([^_]*?))\.(jpg|png|jpeg|webp)(
|
|||
reddit_regex = re.compile('(^|\s|<p>)\/?((r|u)\/(\w|-){3,25})', flags=re.A)
|
||||
sub_regex = re.compile('(^|\s|<p>)\/?(s\/(\w|-){3,25})', flags=re.A)
|
||||
youtube_regex = re.compile('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))</a>(?!</code>)', flags=re.A)
|
||||
strikethrough_regex = re.compile('~~(.*?)~~', flags=re.A)
|
||||
strikethrough_regex = re.compile('~{1,2}([^~]+)~{1,2}', flags=re.A)
|
||||
|
||||
emoji_regex = re.compile("[^a]>\s*(:[!#]{0,2}\w+:\s*)+<\/", flags=re.A)
|
||||
emoji_regex2 = re.compile('(?<!"):([!#A-Za-z0-9]{1,30}?):', flags=re.A)
|
||||
|
|
|
@ -113,6 +113,8 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False, edit=False):
|
|||
|
||||
sanitized = markdown(sanitized)
|
||||
|
||||
sanitized = strikethrough_regex.sub(r'<del>\1</del>', sanitized)
|
||||
|
||||
sanitized = sanitized.replace("\ufeff", "").replace("𒐪","").replace("<script","").replace("script>","").replace('','')
|
||||
|
||||
if alert:
|
||||
|
|
|
@ -213,9 +213,11 @@ def api_comment(v):
|
|||
if v.marseyawarded and parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
if not marsey_regex.fullmatch(body): 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
|
||||
elif v.bird and len(body) > 140 and parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
return {"error":"You have to type less than 140 characters!"}, 403
|
||||
if parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
|
||||
return {"error":"You have to type more than 280 characters!"}, 403
|
||||
elif v.bird and 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
|
||||
|
||||
|
@ -339,13 +341,6 @@ def api_comment(v):
|
|||
|
||||
body_html = sanitize(body, comment=True)
|
||||
|
||||
if parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
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)
|
||||
|
||||
if bans:
|
||||
|
@ -725,8 +720,10 @@ def edit_comment(cid, v):
|
|||
if v.marseyawarded and not marsey_regex.fullmatch(body):
|
||||
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
|
||||
elif v.bird and len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 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
|
||||
elif v.bird and len(body) > 140:
|
||||
return {"error":"You have to type less than 140 characters!"}, 403
|
||||
|
||||
body = image_regex.sub(r'![](\1)', body)
|
||||
|
||||
|
@ -761,11 +758,6 @@ def edit_comment(cid, v):
|
|||
|
||||
body_html = sanitize(body, edit=True)
|
||||
|
||||
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)
|
||||
|
||||
if bans:
|
||||
|
|
|
@ -467,8 +467,10 @@ def edit_post(pid, v):
|
|||
if v.marseyawarded and (not marsey_regex.fullmatch(title) or body and not marsey_regex.fullmatch(body)):
|
||||
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
|
||||
elif v.bird and len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 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
|
||||
elif v.bird and len(body) > 140:
|
||||
return {"error":"You have to type less than 140 characters!"}, 403
|
||||
|
||||
if title != p.title:
|
||||
if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username)
|
||||
|
@ -536,11 +538,6 @@ def edit_post(pid, v):
|
|||
|
||||
p.body = body
|
||||
|
||||
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
|
||||
|
||||
if len(body_html) > 40000: return {"error":"Submission body too long!"}, 400
|
||||
|
||||
p.body_html = body_html
|
||||
|
@ -849,10 +846,10 @@ def submit_post(v, sub=None):
|
|||
title_html = filter_emojis_only(title, graceful=True)
|
||||
if len(title_html) > 1500: return error("Rendered title is too big!")
|
||||
|
||||
if v.longpost:
|
||||
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return error("You have to type more than 280 characters!")
|
||||
elif v.bird:
|
||||
if len(body) > 140 : return error("You have to type less than 140 characters!")
|
||||
if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
|
||||
return {"error":"You have to type more than 280 characters!"}, 403
|
||||
elif v.bird and len(body) > 140:
|
||||
return {"error":"You have to type less than 140 characters!"}, 403
|
||||
|
||||
|
||||
embed = None
|
||||
|
@ -946,9 +943,6 @@ def submit_post(v, sub=None):
|
|||
if v.marseyawarded and (not marsey_regex.fullmatch(title) or body and not marsey_regex.fullmatch(body)):
|
||||
return error("You can only type marseys!")
|
||||
|
||||
if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return error("You have to type more than 280 characters!")
|
||||
elif v.bird and len(body) > 140: return error("You have to type less than 140 characters!")
|
||||
|
||||
dup = g.db.query(Submission).filter(
|
||||
Submission.author_id == v.id,
|
||||
Submission.deleted_utc == 0,
|
||||
|
@ -1052,11 +1046,6 @@ def submit_post(v, sub=None):
|
|||
|
||||
body_html = sanitize(body)
|
||||
|
||||
if v.longpost:
|
||||
if len(body) < 280 or ' [](' in body or body.startswith('[]('): return error("You have to type more than 280 characters!")
|
||||
elif v.bird:
|
||||
if len(body) > 140 : return error("You have to type less than 140 characters!")
|
||||
|
||||
if len(body_html) > 40000: return error("Submission body too long!")
|
||||
|
||||
bans = filter_comment_html(body_html)
|
||||
|
|
Loading…
Reference in New Issue