fd
This commit is contained in:
parent
81b22840cc
commit
1ba76e5d5e
3 changed files with 26 additions and 3 deletions
|
@ -147,7 +147,7 @@ def send_unblock_notif(vid, user, text):
|
||||||
|
|
||||||
def send_pm(vid, user, text):
|
def send_pm(vid, user, text):
|
||||||
|
|
||||||
text_html = mistletoe.Document(text)
|
text_html = Renderer().render(mistletoe.Document(text))
|
||||||
|
|
||||||
text_html = sanitize(text_html, True)
|
text_html = sanitize(text_html, True)
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ 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")
|
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")
|
||||||
|
|
||||||
text_html = mistletoe.Document(text)
|
text_html = Renderer().render(mistletoe.Document(text))
|
||||||
|
|
||||||
text_html = sanitize(text_html, True)
|
text_html = sanitize(text_html, True)
|
||||||
|
|
||||||
|
|
|
@ -98,3 +98,26 @@ class CustomRenderer(HTMLRenderer):
|
||||||
space = token.target[0]
|
space = token.target[0]
|
||||||
target = token.target[1]
|
target = token.target[1]
|
||||||
return f'{space}<a href="https://old.reddit.com/u/{target}" rel="nofollow noopener noreferrer" class="d-inline-block">u/{target}</a>'
|
return f'{space}<a href="https://old.reddit.com/u/{target}" rel="nofollow noopener noreferrer" class="d-inline-block">u/{target}</a>'
|
||||||
|
|
||||||
|
|
||||||
|
class Renderer(HTMLRenderer):
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
super().__init__(SubMention,
|
||||||
|
RedditorMention,
|
||||||
|
SubMention2,
|
||||||
|
RedditorMention2,
|
||||||
|
)
|
||||||
|
|
||||||
|
for i in kwargs:
|
||||||
|
self.__dict__[i] = kwargs[i]
|
||||||
|
|
||||||
|
def render_sub_mention(self, token):
|
||||||
|
space = token.target[0]
|
||||||
|
target = token.target[1]
|
||||||
|
return f'{space}<a href="https://old.reddit.com/r/{target}" rel="nofollow noopener noreferrer" class="d-inline-block">r/{target}</a>'
|
||||||
|
|
||||||
|
def render_redditor_mention(self, token):
|
||||||
|
space = token.target[0]
|
||||||
|
target = token.target[1]
|
||||||
|
return f'{space}<a href="https://old.reddit.com/u/{target}" rel="nofollow noopener noreferrer" class="d-inline-block">u/{target}</a>'
|
|
@ -256,7 +256,7 @@ def messagereply(v):
|
||||||
if existing.parent_comment_id: return redirect(f'/notifications?messages=true#comment-{existing.parent_comment_id}')
|
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}')
|
else: return redirect(f'/notifications?messages=true#comment-{existing.id}')
|
||||||
|
|
||||||
text_html = mistletoe.Document(message)
|
text_html = Renderer().render(mistletoe.Document(message))
|
||||||
text_html = sanitize(text_html, True)
|
text_html = sanitize(text_html, True)
|
||||||
new_comment = Comment(author_id=v.id,
|
new_comment = Comment(author_id=v.id,
|
||||||
parent_submission=None,
|
parent_submission=None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue