This commit is contained in:
Aevann1 2021-09-13 13:45:03 +02:00
parent ab46a01b53
commit bcd3252777
45 changed files with 36 additions and 39 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 158 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 308 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 325 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 159 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 KiB

After

Width:  |  Height:  |  Size: 199 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 260 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 125 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 289 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 159 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 185 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 218 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 312 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 KiB

After

Width:  |  Height:  |  Size: 220 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 135 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 172 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 110 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 KiB

After

Width:  |  Height:  |  Size: 137 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 212 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

After

Width:  |  Height:  |  Size: 104 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 86 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 87 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 119 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 129 KiB

After

Width:  |  Height:  |  Size: 72 KiB

Before After
Before After

View file

@ -20,8 +20,7 @@ def send_notification(vid, user, text, db=None):
text = text.replace('r/', 'r\/').replace('u/', 'u\/')
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 = CustomRenderer().render(mistletoe.Document(text))
text_html = sanitize(text_html)
@ -44,33 +43,11 @@ def send_notification(vid, user, text, db=None):
db.add(notif)
def send_pm(vid, user, text):
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text))
text_html = sanitize(text_html, True)
new_comment = Comment(author_id=vid,
parent_submission=None,
level=1,
sentto=user.id
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id, user_id=user.id)
g.db.add(notif)
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 = CustomRenderer().render(mistletoe.Document(text))
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
@ -95,8 +72,7 @@ def send_unfollow_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 = CustomRenderer().render(mistletoe.Document(text))
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
@ -121,8 +97,7 @@ def send_block_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 = CustomRenderer().render(mistletoe.Document(text))
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
@ -147,8 +122,7 @@ def send_unblock_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 = CustomRenderer().render(mistletoe.Document(text))
text_html = sanitize(text_html)
new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT,
@ -169,11 +143,36 @@ def send_unblock_notif(vid, user, text):
unblocksender=vid)
g.db.add(notif)
def send_pm(vid, user, text):
text_html = mistletoe.Document(text)
text_html = sanitize(text_html, True)
new_comment = Comment(author_id=vid,
parent_submission=None,
level=1,
sentto=user.id
)
g.db.add(new_comment)
g.db.flush()
new_aux = CommentAux(id=new_comment.id, body=text, body_html=text_html)
g.db.add(new_aux)
notif = Notification(comment_id=new_comment.id, user_id=user.id)
g.db.add(notif)
def send_admin(vid, 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 = mistletoe.Document(text)
text_html = sanitize(text_html, True)

View file

@ -920,8 +920,7 @@ def ban_post(post_id, v):
ban_reason=request.form.get("reason", "")
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 = CustomRenderer().render(mistletoe.Document(ban_reason))
ban_reason = sanitize(ban_reason)
post.ban_reason = ban_reason

View file

@ -247,7 +247,7 @@ def edit_post(pid, v):
if body != p.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_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)
# Run safety filter
@ -798,8 +798,7 @@ def submit_post(v):
# render text
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() as renderer:
body_md = renderer.render(mistletoe.Document(body))
body_md = CustomRenderer().render(mistletoe.Document(body))
body_html = sanitize(body_md)
# Run safety filter

View file

@ -123,7 +123,7 @@ def settings_profile_post(v):
# v=v,
# error="You didn't change anything")
with CustomRenderer() as renderer: bio_html = renderer.render(mistletoe.Document(bio))
bio_html = CustomRenderer().render(mistletoe.Document(bio))
bio_html = sanitize(bio_html)
# Run safety filter
bans = filter_comment_html(bio_html)

View file

@ -256,7 +256,7 @@ def messagereply(v):
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
else: return redirect(f'/notifications?messages=true#comment-{existing.id}')
with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(message))
text_html = CustomRenderer().render(mistletoe.Document(message))
text_html = sanitize(text_html, True)
new_comment = Comment(author_id=v.id,
parent_submission=None,