fix issue with text exceeding character count despite not exceeding it

remotes/1693045480750635534/spooky-22
Aevann1 2022-06-29 03:13:11 +02:00
parent b6a5d010ca
commit b602a66dd6
3 changed files with 12 additions and 7 deletions

View File

@ -163,7 +163,9 @@ def api_comment(v):
if parent.author_id == v.id: rts = True
else: abort(400)
body = request.values.get("body", "").strip()[:10000]
body = request.values.get("body", "").strip().replace('','')
body = body.replace('\r\n', '\n')[:10000]
if parent_post.id not in ADMIGGERS:
if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
@ -644,7 +646,9 @@ def edit_comment(cid, v):
if c.author_id != v.id: abort(403)
body = request.values.get("body", "").strip()[:10000]
body = request.values.get("body", "").strip().replace('','')
body = body.replace('\r\n', '\n')[:10000]
if len(body) < 1 and not (request.files.get("file") and request.headers.get("cf-ipcountry") != "T1"):
return {"error":"You have to actually type something!"}, 400

View File

@ -399,7 +399,7 @@ def edit_post(pid, v):
body = request.values.get("body", "").strip().replace('','')
if len(body) > 20000: return {"error":"Character limit is 20000!"}, 403
body = body.replace('\r\n', '\n')[:20000]
if v.id == p.author_id:
if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')):
@ -717,6 +717,8 @@ def submit_post(v, sub=None):
body = request.values.get("body", "").strip().replace('','')
body = body.replace('\r\n', '\n')[:20000]
def error(error):
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": error}, 403
@ -890,9 +892,6 @@ def submit_post(v, sub=None):
g.db.add(ma)
return redirect("/notifications")
if len(str(body)) > 20000:
return error("There's a 20000 character limit for text body.")
if len(url) > 2048:
return error("There's a 2048 character limit for URLs.")

View File

@ -700,7 +700,9 @@ def message2(v, username):
@auth_required
def messagereply(v):
body = request.values.get("body", "").strip()[:10000].strip()
body = request.values.get("body", "").strip().replace('','')
body = body.replace('\r\n', '\n')[:10000]
if not body and not request.files.get("file"): return {"error": "Message is empty!"}