From e1853befaaed5a5b160419b40f1da35b1a6f556b Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 29 Jul 2023 22:17:50 +0300 Subject: [PATCH] restore needful .strip() --- files/routes/comments.py | 4 ++-- files/routes/posts.py | 8 ++++---- files/routes/users.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 0842211c1..a73ab19e8 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -153,7 +153,7 @@ def comment(v:User): if level > COMMENT_MAX_DEPTH: abort(400, f"Max comment level is {COMMENT_MAX_DEPTH}") body = request.values.get("body", "") - body = body[:COMMENT_BODY_LENGTH_LIMIT] + body = body[:COMMENT_BODY_LENGTH_LIMIT].strip() if not posting_to_post or post_target.id not in ADMIGGER_THREADS: if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')): @@ -614,7 +614,7 @@ def edit_comment(cid, v): abort(403) body = request.values.get("body", "") - body = body[:COMMENT_BODY_LENGTH_LIMIT] + body = body[:COMMENT_BODY_LENGTH_LIMIT].strip() if len(body) < 1 and not (request.files.get("file") and not g.is_tor): abort(400, "You have to actually type something!") diff --git a/files/routes/posts.py b/files/routes/posts.py index 4e590fe3d..435fd1794 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -465,10 +465,10 @@ def submit_post(v:User, sub=None): if '\\' in url: abort(400) title = request.values.get("title", "") - title = title[:POST_TITLE_LENGTH_LIMIT] + title = title[:POST_TITLE_LENGTH_LIMIT].strip() body = request.values.get("body", "") - body = body[:POST_BODY_LENGTH_LIMIT(g.v)] + body = body[:POST_BODY_LENGTH_LIMIT(g.v)].strip() post_ping_group_count = len(list(group_mention_regex.finditer(body))) @@ -1042,10 +1042,10 @@ def edit_post(pid, v): abort(403, "You can't edit posts older than 1 week!") title = request.values.get("title", "") - title = title[:POST_TITLE_LENGTH_LIMIT] + title = title[:POST_TITLE_LENGTH_LIMIT].strip() body = request.values.get("body", "") - body = body[:POST_BODY_LENGTH_LIMIT(g.v)] + body = body[:POST_BODY_LENGTH_LIMIT(g.v)].strip() if v.id == p.author_id: if v.longpost and (len(body) < 280 or ' [](' in body or body.startswith('[](')): diff --git a/files/routes/users.py b/files/routes/users.py index 84dff6551..e3648fe2f 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -623,7 +623,7 @@ def message2(v, username=None, id=None): abort(403, f"@{user.username} is blocking you!") body = request.values.get("message", "") - body = body[:COMMENT_BODY_LENGTH_LIMIT] + body = body[:COMMENT_BODY_LENGTH_LIMIT].strip() if not g.is_tor and get_setting("dm_media"): body = process_files(request.files, v, body, is_dm=True, dm_user=user) @@ -679,7 +679,7 @@ def message2(v, username=None, id=None): @auth_required def messagereply(v:User): body = request.values.get("body", "") - body = body[:COMMENT_BODY_LENGTH_LIMIT] + body = body[:COMMENT_BODY_LENGTH_LIMIT].strip() id = request.values.get("parent_id") parent = get_comment(id, v=v)