From 69e8a4bcd6d745ac2cb78db7575a35c40b9c6bee Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 4 Nov 2021 22:34:08 +0200 Subject: [PATCH] sdfsfd --- files/routes/comments.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index 4c5d9ed5ae..55d449aae6 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -167,11 +167,10 @@ def api_comment(v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - body_md = body options = [] - for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body_md): + for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body): options.append(i.group(1)) - body_md = body_md.replace(i.group(0), "") + body = body.replace(i.group(0), "") if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1": file=request.files["file"] @@ -181,12 +180,9 @@ def api_comment(v): file.save(name) url = request.host_url[:-1] + process_image(name) - body = request.values.get("body") + f"\n![]({url})" - body_md = CustomRenderer().render(mistletoe.Document(body)) - body_html = sanitize(body_md) - else: - body_md = CustomRenderer().render(mistletoe.Document(body_md)) - body_html = sanitize(body_md) + body += f"\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!"}, 403