From 08b4cd6e036762e9ad3b861efae803d6aa35519b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 21 Aug 2021 14:57:16 +0200 Subject: [PATCH] dffd --- files/helpers/alerts.py | 14 +++++++------- files/routes/admin.py | 4 ++-- files/routes/comments.py | 16 ++++++++-------- files/routes/posts.py | 6 +++--- files/routes/settings.py | 2 +- files/routes/users.py | 2 +- files/templates/submission_listing.html | 20 +++++++++++--------- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index ee7695127..8bcc7afc4 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -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, diff --git a/files/routes/admin.py b/files/routes/admin.py index f9ebdf057..7cccd265c 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -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 diff --git a/files/routes/comments.py b/files/routes/comments.py index 3ca258478..6a58fd6ef 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -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 diff --git a/files/routes/posts.py b/files/routes/posts.py index d350cdde1..44ba6a660 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -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, diff --git a/files/routes/settings.py b/files/routes/settings.py index 6055523eb..8e9a4b969 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -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) diff --git a/files/routes/users.py b/files/routes/users.py index 9d89cee0b..4c853d9f3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -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, diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 6b0f6e621..4eb2c19e9 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -116,15 +116,15 @@ {% if p.active_flags %} -
- Reported by: -

-				
-			
+
+ Reported by: +

+					
+				
{% endif %}
@@ -386,6 +386,8 @@ +{% else %} + {% if request.path.endswith('/admin/queue') %}