From b72325886e594467f5479d022722bbc863b441ed Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 13 Sep 2021 13:54:20 +0200 Subject: [PATCH] fd --- files/routes/comments.py | 32 +++++++++++++------------------- files/routes/posts.py | 14 +++++--------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index bb7c04fea2..52d0ac47d3 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -166,7 +166,7 @@ def api_comment(v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") - with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) # Run safety filter @@ -293,8 +293,7 @@ def api_comment(v): body = request.form.get("body") + f"\n![]({url})" body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") - with CustomRenderer(post_id=parent_id) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) if len(body_html) > 20000: abort(400) @@ -330,7 +329,7 @@ def api_comment(v): body2 = BASED_MSG.format(username=basedguy.username, basedcount=basedguy.basedcount, pills=basedguy.pills) - with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body2)) + body_md = CustomRenderer().render(mistletoe.Document(body2)) body_based_html = sanitize(body_md) c_aux = CommentAux( @@ -365,8 +364,7 @@ def api_comment(v): body2 = VAXX_MSG.format(username=v.username) - with CustomRenderer(post_id=parent_id) as renderer: - body_md = renderer.render(mistletoe.Document(body2)) + body_md = CustomRenderer().render(mistletoe.Document(body2)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -399,8 +397,7 @@ def api_comment(v): body = AGENDAPOSTER_MSG.format(username=v.username) - with CustomRenderer(post_id=parent_id) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -426,7 +423,7 @@ def api_comment(v): body = random.choice(LONGPOST_REPLIES) body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") - with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html2 = sanitize(body_md) c_aux = CommentAux( id=c2.id, @@ -456,7 +453,7 @@ def api_comment(v): g.db.flush() body = "zoz" - with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html2 = sanitize(body_md) c_aux = CommentAux( id=c2.id, @@ -482,7 +479,7 @@ def api_comment(v): g.db.flush() body = "zle" - with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html2 = sanitize(body_md) c_aux = CommentAux( id=c3.id, @@ -508,7 +505,7 @@ def api_comment(v): g.db.flush() body = "zozzle" - with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html2 = sanitize(body_md) c_aux = CommentAux( id=c4.id, @@ -614,7 +611,7 @@ def edit_comment(cid, v): body = request.form.get("body", "")[:10000] for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', body, re.MULTILINE): body = body.replace(i.group(1), f'![]({i.group(1)})') body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") - with CustomRenderer(post_id=c.post.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) bans = filter_comment_html(body_html) @@ -709,8 +706,7 @@ def edit_comment(cid, v): else: url = upload_imgur(file=file) body += f"\n![]({url})" - with CustomRenderer(post_id=c.parent_submission) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) if len(body_html) > 20000: abort(400) @@ -738,8 +734,7 @@ def edit_comment(cid, v): body = VAXX_MSG.format(username=v.username) - with CustomRenderer(post_id=c.parent_submission) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -773,8 +768,7 @@ def edit_comment(cid, v): body = AGENDAPOSTER_MSG.format(username=v.username) - with CustomRenderer(post_id=c.parent_submission) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( diff --git a/files/routes/posts.py b/files/routes/posts.py index dc0bb0201c..7ab5d1a5c3 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -318,8 +318,7 @@ def edit_post(pid, v): body = VAXX_MSG.format(username=v.username) - with CustomRenderer(post_id=p.id) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -355,8 +354,7 @@ def edit_post(pid, v): body = AGENDAPOSTER_MSG.format(username=v.username) - with CustomRenderer(post_id=p.id) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -989,8 +987,7 @@ def submit_post(v): body = VAXX_MSG.format(username=v.username) - with CustomRenderer(post_id=new_post.id) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -1026,8 +1023,7 @@ def submit_post(v): body = AGENDAPOSTER_MSG.format(username=v.username) - with CustomRenderer(post_id=new_post.id) as renderer: - body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_jannied_html = sanitize(body_md) c_aux = CommentAux( @@ -1069,7 +1065,7 @@ def submit_post(v): if new_post.url: body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={urllib.parse.quote(new_post.url)}&run=1) (click to archive)" gevent.spawn(archiveorg, new_post.url) - with CustomRenderer(post_id=new_post.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) c_aux = CommentAux( id=c.id,