fix 500 errors

pull/143/head
Aevann 2023-04-29 15:33:29 +02:00
parent 433c05ee34
commit 8ef54cb720
3 changed files with 8 additions and 2 deletions

View File

@ -606,7 +606,7 @@ def POST_BODY_LENGTH_LIMIT(v):
POST_BODY_HTML_LENGTH_LIMIT = 200000 # do not make larger than 200000 without altering the table
COMMENT_BODY_LENGTH_LIMIT = 10000 # do not make larger than 10000 characters without altering the table
COMMENT_BODY_HTML_LENGTH_LIMIT = 20000 # do not make larger than 20000 characters without altering the table
COMMENT_BODY_HTML_LENGTH_LIMIT = 40000 # do not make larger than 20000 characters without altering the table
CSS_LENGTH_LIMIT = 10000 # do not make larger than 20000 characters without altering the table
COMMENT_MAX_DEPTH = 200
TRANSFER_MESSAGE_LENGTH_LIMIT = 200 # do not make larger than 10000 characters (comment limit) without altering the table

View File

@ -256,7 +256,8 @@ def comment(v:User):
if v.marseyawarded and posting_to_submission and post_target.id not in ADMIGGER_THREADS and marseyaward_body_regex.search(body_html):
abort(403, "You can only type marseys!")
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT: abort(400)
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
abort(400, "Comment too long!")
is_bot = v.client is not None and v.id not in PRIVILEGED_USER_BOTS

View File

@ -598,10 +598,15 @@ def messagereply(v:User):
body = process_dm_images(v, user, body)
body = body.strip()[:COMMENT_BODY_LENGTH_LIMIT]
if not body: abort(400, "Message is empty!")
body_html = sanitize(body)
if len(body_html) > COMMENT_BODY_HTML_LENGTH_LIMIT:
abort(400, "Message too long!")
if parent.sentto == MODMAIL_ID:
sentto = MODMAIL_ID
else: