remotes/1693045480750635534/spooky-22
Aevann1 2021-08-21 14:57:16 +02:00
parent b40a676f85
commit 08b4cd6e03
7 changed files with 33 additions and 31 deletions

View File

@ -13,7 +13,7 @@ def send_notification(vid, user, text):
with CustomRenderer() as renderer:
text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=vid,
parent_submission=None,
@ -38,7 +38,7 @@ def send_pm(vid, user, text):
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=vid,
parent_submission=None,
@ -61,7 +61,7 @@ def send_follow_notif(vid, user, text):
text = text.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() as renderer: text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=1046,
parent_submission=None,
@ -87,7 +87,7 @@ def send_unfollow_notif(vid, user, text):
with CustomRenderer() as renderer:
text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=1046,
parent_submission=None,
@ -113,7 +113,7 @@ def send_block_notif(vid, user, text):
with CustomRenderer() as renderer:
text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=1046,
parent_submission=None,
@ -139,7 +139,7 @@ def send_unblock_notif(vid, user, text):
with CustomRenderer() as renderer:
text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=1046,
parent_submission=None,
@ -165,7 +165,7 @@ def send_admin(vid, text):
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
new_comment = Comment(author_id=vid,
parent_submission=None,

View File

@ -566,7 +566,7 @@ def admin_title_change(user_id, v):
new_name=request.form.get("title").strip()
user.customtitleplain=new_name
new_name = sanitize(new_name, linkgen=True)
new_name = sanitize(new_name)
user=g.db.query(User).with_for_update().options(lazyload('*')).filter_by(id=user.id).first()
user.customtitle=new_name
@ -703,7 +703,7 @@ def ban_post(post_id, v):
ban_reason = ban_reason.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() as renderer:
ban_reason = renderer.render(mistletoe.Document(ban_reason))
ban_reason = sanitize(ban_reason, linkgen=True)
ban_reason = sanitize(ban_reason)
post.ban_reason = ban_reason

View File

@ -161,7 +161,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_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
# Run safety filter
bans = filter_comment_html(body_html)
@ -284,7 +284,7 @@ def api_comment(v):
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_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
c_aux = CommentAux(
id=c.id,
@ -349,7 +349,7 @@ def api_comment(v):
body = random.choice(choices)
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_html2 = sanitize(body_md, linkgen=True)
body_html2 = sanitize(body_md)
c_aux = CommentAux(
id=c2.id,
body_html=body_html2,
@ -379,7 +379,7 @@ def api_comment(v):
body = "zoz"
with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body))
body_html2 = sanitize(body_md, linkgen=True)
body_html2 = sanitize(body_md)
c_aux = CommentAux(
id=c2.id,
body_html=body_html2,
@ -405,7 +405,7 @@ def api_comment(v):
body = "zle"
with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body))
body_html2 = sanitize(body_md, linkgen=True)
body_html2 = sanitize(body_md)
c_aux = CommentAux(
id=c3.id,
body_html=body_html2,
@ -431,7 +431,7 @@ def api_comment(v):
body = "zozzle"
with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body))
body_html2 = sanitize(body_md, linkgen=True)
body_html2 = sanitize(body_md)
c_aux = CommentAux(
id=c4.id,
body_html=body_html2,
@ -538,7 +538,7 @@ def edit_comment(cid, 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=c.post.id) as renderer: body_md = renderer.render(mistletoe.Document(body))
body_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
bans = filter_comment_html(body_html)
@ -632,7 +632,7 @@ def edit_comment(cid, v):
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.parent_submission) as renderer:
body_md = renderer.render(mistletoe.Document(body))
body_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
c.body = body
c.body_html = body_html

View File

@ -240,7 +240,7 @@ def edit_post(pid, v):
body = request.form.get("body", "")
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)})')
with CustomRenderer() as renderer: body_md = renderer.render(mistletoe.Document(body))
body_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
# Run safety filter
bans = filter_comment_html(body_html)
@ -708,7 +708,7 @@ def submit_post(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)})')
with CustomRenderer() as renderer:
body_md = renderer.render(mistletoe.Document(body))
body_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
# Run safety filter
bans = filter_comment_html(body_html)
@ -902,7 +902,7 @@ def submit_post(v):
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_html = sanitize(body_md, linkgen=True)
body_html = sanitize(body_md)
c_aux = CommentAux(
id=c.id,
body_html=body_html,

View File

@ -81,7 +81,7 @@ def settings_profile_post(v):
for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|PNG|JPG|JPEG|GIF|9999))', bio, re.MULTILINE): bio = bio.replace(i.group(1), f'![]({i.group(1)})')
bio = bio.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() as renderer: bio_html = renderer.render(mistletoe.Document(bio))
bio_html = sanitize(bio_html, linkgen=True)
bio_html = sanitize(bio_html)
# Run safety filter
bans = filter_comment_html(bio_html)

View File

@ -116,7 +116,7 @@ def messagereply(v, username, id):
if existing: return redirect('/notifications?messages=true')
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message))
text_html = sanitize(text_html, linkgen=True)
text_html = sanitize(text_html)
parent = get_comment(int(id), v=v)
new_comment = Comment(author_id=v.id,
parent_submission=None,

View File

@ -116,15 +116,15 @@
</div>
{% if p.active_flags %}
<div id="flaggers-{{p.id}}" class="flaggers d-none">
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<pre></pre>
<ul style="padding-left:20px; margin-bottom: 0;">
{% for f in p.ordered_flags %}
<li><a style="font-weight:bold" href="{{f.user.url}}">@{{f.user.username}}</a>{% if f.reason %}: {{f.reason | safe}}{% endif %}</li>
{% endfor %}
</ul>
</div>
<div id="flaggers-{{p.id}}" class="flaggers d-none">
<strong><i class="far fa-fw fa-flag"></i> Reported by:</strong>
<pre></pre>
<ul style="padding-left:20px; margin-bottom: 0;">
{% for f in p.ordered_flags %}
<li><a style="font-weight:bold" href="{{f.user.url}}">@{{f.user.username}}</a>{% if f.reason %}: {{f.reason | safe}}{% endif %}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<h5 class="card-title post-title text-left w-lg-75 mb-0 pb-0 pb-md-1"><a {% if v and v.newtab %}target="_blank"{% endif %} {% if v %}href="{{p.permalink}}"{% else %}href="/logged_out{{p.permalink}}"{% endif %} class="stretched-link" {% if p.author.is_private %} rel="nofollow"{% endif %}>
@ -386,6 +386,8 @@
</div>
{% else %}
{% if request.path.endswith('/admin/queue') %}
<div class="row no-gutters">