From 57dd3a37f448fe40e4ea55c0fb4ea7e06441b513 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 30 Nov 2021 20:25:41 +0200 Subject: [PATCH] sdfsfd --- files/routes/posts.py | 10 ++++++++++ files/templates/submit.html | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 24cc88b34..195a13733 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -755,6 +755,16 @@ def submit_post(v): body = body.replace('I ', f'@{v.username} ') body = censor_slurs2(body).upper().replace(' ME ', f' @{v.username} ') + if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1": + file=request.files["file2"] + if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400 + + name = f'/images/{int(time.time())}{secrets.token_urlsafe(2)}.webp' + file.save(name) + url = request.host_url[:-1] + process_image(name) + + body += f"\n\n![]({url})" + body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 400 diff --git a/files/templates/submit.html b/files/templates/submit.html index 96b5cc63c..e01bf1cc4 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -117,7 +117,12 @@ - + + +

 												
Formatting help