From d7a34752e1169b810c413de40ae3bf476edbe99c Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 10 Dec 2021 21:39:48 +0200 Subject: [PATCH] fdsfds --- files/routes/comments.py | 8 ++++++-- files/routes/posts.py | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 23ab85e8a..633544e42 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -157,7 +157,9 @@ def api_comment(v): else: top_comment_id = parent.top_comment_id else: abort(400) - body = request.values.get("body", "").strip()[:10000] + body = request.values.get("body", "").strip()[:10000].replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if v.marseyawarded: if time.time() > v.marseyawarded: @@ -615,7 +617,9 @@ def edit_comment(cid, v): if c.is_banned or c.deleted_utc > 0: abort(403) - body = request.values.get("body", "").strip()[:10000] + body = request.values.get("body", "").strip()[:10000].replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if len(body) < 1: return {"error":"You have to actually type something!"}, 400 if body != c.body and body != "": diff --git a/files/routes/posts.py b/files/routes/posts.py index 7598798ef..bbbe5e26c 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -335,8 +335,12 @@ def edit_post(pid, v): if p.author_id != v.id and not (v.admin_level > 1 and v.admin_level > 2): abort(403) - title = request.values.get("title", "").strip() - body = request.values.get("body", "").strip() + title = request.values.get("title", "").strip().replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', title): + title = title.replace(i.group(2), i.group(2).upper()) + body = request.values.get("body", "").strip().replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403 @@ -669,7 +673,9 @@ def submit_post(v): if request.content_length > 8 * 1024 * 1024: return "Max file size is 8 MB.", 413 elif request.content_length > 4 * 1024 * 1024: return "Max file size is 4 MB.", 413 - title = request.values.get("title", "").strip()[:500] + title = request.values.get("title", "").strip()[:500].replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', title): + title = title.replace(i.group(2), i.group(2).upper()) url = request.values.get("url", "").strip() if v.agendaposter and not v.marseyawarded: @@ -678,7 +684,9 @@ def submit_post(v): title = censor_slurs2(title).upper().replace(' ME ', f' @{v.username} ') title_html = filter_emojis_only(title) - body = request.values.get("body", "").strip() + body = request.values.get("body", "").strip().replace(' ','\n') + for i in re.finditer('(^|\n)(?!.*http)(.*)', body): + body = body.replace(i.group(2), i.group(2).upper()) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 40