fd
This commit is contained in:
parent
f788a84093
commit
e324257dce
61 changed files with 106 additions and 112 deletions
|
@ -40,8 +40,6 @@ WORDLE_COLOR_MAPPINGS = {-1: "🟥", 0: "🟨", 1: "🟩"}
|
|||
def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
||||
|
||||
if not v and not request.path.startswith('/logged_out'): return redirect(f"{SITE_FULL}/logged_out{request.full_path}")
|
||||
|
||||
if v and request.path.startswith('/logged_out'): return redirect(SITE_FULL + request.full_path.replace('/logged_out',''))
|
||||
|
||||
try: cid = int(cid)
|
||||
except: abort(404)
|
||||
|
@ -145,7 +143,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None, sub=None):
|
|||
def api_comment(v):
|
||||
if v.is_suspended: return {"error": "You can't perform this action while banned."}, 403
|
||||
|
||||
if v.admin_level < 2:
|
||||
if v.admin_level < 3:
|
||||
if v and v.patron:
|
||||
if request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 4 MB (8 MB for paypigs)."}, 413
|
||||
elif request.content_length > 4 * 1024 * 1024: return {"error":"Max file size is 4 MB (8 MB for paypigs)."}, 413
|
||||
|
@ -181,7 +179,7 @@ def api_comment(v):
|
|||
f.write('\n{[para]}\n' + body)
|
||||
|
||||
if v.marseyawarded and parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, re.A))
|
||||
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, flags=re.A))
|
||||
if len(marregex) == 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
|
||||
|
@ -190,16 +188,16 @@ def api_comment(v):
|
|||
|
||||
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)($|\s|\n))', body, re.M|re.A):
|
||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999)($|\s|\n))', body, flags=re.M|re.A):
|
||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||
|
||||
options = []
|
||||
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body, re.A):
|
||||
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body, flags=re.A):
|
||||
options.append(i.group(1))
|
||||
body = body.replace(i.group(0), "")
|
||||
|
||||
choices = []
|
||||
for i in re.finditer('\s*&&([^\$\n]+)&&\s*', body, re.A):
|
||||
for i in re.finditer('\s*&&([^\$\n]+)&&\s*', body, flags=re.A):
|
||||
choices.append(i.group(1))
|
||||
body = body.replace(i.group(0), "")
|
||||
|
||||
|
@ -275,7 +273,7 @@ def api_comment(v):
|
|||
|
||||
body_html = sanitize(body, comment=True)
|
||||
|
||||
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html, re.A))): return {"error":"You can only type marseys!"}, 403
|
||||
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html, flags=re.A))): return {"error":"You can only type marseys!"}, 403
|
||||
|
||||
if parent_post.id not in (37696,37697,37749,37833,37838):
|
||||
if v.longpost:
|
||||
|
@ -388,7 +386,7 @@ def api_comment(v):
|
|||
g.db.add(c_choice)
|
||||
|
||||
if request.host == 'pcmemes.net' and c.body.lower().startswith("based"):
|
||||
pill = re.match("based and (.{1,20}?)(-| )pilled", body, re.IGNORECASE)
|
||||
pill = re.match("based and (.{1,20}?)(-| )pilled", body, flags=re.IGNORECASE)
|
||||
|
||||
if level == 1: basedguy = get_account(parent_post.author_id)
|
||||
else: basedguy = get_account(c.parent_comment.author_id)
|
||||
|
@ -695,7 +693,7 @@ def api_comment(v):
|
|||
@auth_required
|
||||
def edit_comment(cid, v):
|
||||
|
||||
if v.admin_level < 2:
|
||||
if v.admin_level < 3:
|
||||
if v and v.patron:
|
||||
if request.content_length > 8 * 1024 * 1024: return {"error":"Max file size is 4 MB (8 MB for paypigs)."}, 413
|
||||
elif request.content_length > 4 * 1024 * 1024: return {"error":"Max file size is 4 MB (8 MB for paypigs)."}, 413
|
||||
|
@ -711,20 +709,20 @@ def edit_comment(cid, v):
|
|||
|
||||
if body != c.body or request.files.get("file") and request.headers.get("cf-ipcountry") != "T1":
|
||||
if v.marseyawarded:
|
||||
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, re.A))
|
||||
marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body, flags=re.A))
|
||||
if len(marregex) == 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
|
||||
elif v.bird and 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)($|\s|\n))', body, re.M|re.A):
|
||||
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999)($|\s|\n))', body, flags=re.M|re.A):
|
||||
if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'})')
|
||||
|
||||
if v.agendaposter and not v.marseyawarded:
|
||||
body = torture_ap(body, v.username)
|
||||
|
||||
if not c.options:
|
||||
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body, re.A):
|
||||
for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body, flags=re.A):
|
||||
body = body.replace(i.group(0), "")
|
||||
c_option = Comment(author_id=AUTOPOLLER_ID,
|
||||
parent_submission=c.parent_submission,
|
||||
|
@ -737,7 +735,7 @@ def edit_comment(cid, v):
|
|||
g.db.add(c_option)
|
||||
|
||||
if not c.choices:
|
||||
for i in re.finditer('\s*&&([^\$\n]+)&&\s*', body, re.A):
|
||||
for i in re.finditer('\s*&&([^\$\n]+)&&\s*', body, flags=re.A):
|
||||
body = body.replace(i.group(0), "")
|
||||
c_choice = Comment(author_id=AUTOCHOICE_ID,
|
||||
parent_submission=c.parent_submission,
|
||||
|
@ -751,7 +749,7 @@ def edit_comment(cid, v):
|
|||
|
||||
body_html = sanitize(body, edit=True)
|
||||
|
||||
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html, re.A))): return {"error":"You can only type marseys!"}, 403
|
||||
if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html, flags=re.A))): return {"error":"You can only type marseys!"}, 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue