forked from rDrama/rDrama
1
0
Fork 0
master
Aevann1 2021-09-13 13:54:20 +02:00
parent 19c3930678
commit b72325886e
2 changed files with 18 additions and 28 deletions

View File

@ -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(

View File

@ -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,