forked from rDrama/rDrama
dont show <img loading="lazy" data-bs-toggle="tooltip" alt=":marseytrain2:" title=":marseytrain2:" src="https://i.rdrama.net/e/marseytrain2.webp"> when its not rendered
parent
5e8ddaafb2
commit
568f66e070
|
@ -385,8 +385,7 @@ class Comment(Base):
|
|||
if not body: return ""
|
||||
|
||||
if not (self.parent_post and self.post.sub == 'chudrama'):
|
||||
body = censor_slurs_profanities(body, v)
|
||||
body = replace_train_html(body)
|
||||
body = censor_slurs_profanities(body, v, True)
|
||||
|
||||
return body
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class HatDef(Base):
|
|||
|
||||
@lazy
|
||||
def censored_description(self, v):
|
||||
return censor_slurs_profanities(self.description, v)
|
||||
return censor_slurs_profanities(self.description, v, True)
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -316,8 +316,7 @@ class Post(Base):
|
|||
if not body: return ""
|
||||
|
||||
if self.sub != 'chudrama':
|
||||
body = censor_slurs_profanities(body, v)
|
||||
body = replace_train_html(body)
|
||||
body = censor_slurs_profanities(body, v, True)
|
||||
|
||||
body = normalize_urls_runtime(body, v)
|
||||
|
||||
|
@ -337,8 +336,7 @@ class Post(Base):
|
|||
title = self.title
|
||||
|
||||
if self.sub != 'chudrama':
|
||||
title = censor_slurs_profanities(title, v)
|
||||
title = replace_train_html(title)
|
||||
title = censor_slurs_profanities(title, v, True)
|
||||
|
||||
return title
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ def push_notif(uids, title, body, url_or_comment):
|
|||
if len(body) > PUSH_NOTIF_LIMIT:
|
||||
body = body[:PUSH_NOTIF_LIMIT] + "..."
|
||||
|
||||
body = censor_slurs_profanities(body, None)
|
||||
body = censor_slurs_profanities(body, None, True)
|
||||
|
||||
subscriptions = g.db.query(PushSubscription.subscription_json).filter(PushSubscription.user_id.in_(uids)).all()
|
||||
subscriptions = [x[0] for x in subscriptions]
|
||||
|
|
|
@ -5,12 +5,6 @@ tranny = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":marseytrain:" titl
|
|||
trannie = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":!marseytrain:" title=":!marseytrain:" src="{SITE_FULL_IMAGES}/e/marseytrain.webp">'
|
||||
troon = f'<img loading="lazy" data-bs-toggle="tooltip" alt=":marseytrain2:" title=":marseytrain2:" src="{SITE_FULL_IMAGES}/e/marseytrain2.webp">'
|
||||
|
||||
def replace_train_html(body):
|
||||
body = body.replace(tranny, ':marseytrain:')
|
||||
body = body.replace(trannie, ':!marseytrain:')
|
||||
body = body.replace(troon, ':marseytrain2:')
|
||||
return body
|
||||
|
||||
SLURS = {
|
||||
"tranny": tranny,
|
||||
"trannie": trannie,
|
||||
|
@ -152,7 +146,7 @@ def sub_matcher_profanities(match):
|
|||
|
||||
|
||||
|
||||
def censor_slurs_profanities(body, logged_user):
|
||||
def censor_slurs_profanities(body, logged_user, is_plain=False):
|
||||
if not body: return ""
|
||||
|
||||
if '<pre>' in body or '<code>' in body:
|
||||
|
@ -165,4 +159,9 @@ def censor_slurs_profanities(body, logged_user):
|
|||
if not logged_user or logged_user == 'chat' or logged_user.profanityreplacer:
|
||||
body = profanity_regex.sub(sub_matcher_profanities, body)
|
||||
|
||||
if is_plain:
|
||||
body = body.replace(tranny, ':marseytrain:')
|
||||
body = body.replace(trannie, ':!marseytrain:')
|
||||
body = body.replace(troon, ':marseytrain2:')
|
||||
|
||||
return body
|
||||
|
|
|
@ -155,7 +155,7 @@ def speak(data, v):
|
|||
"namecolor": v.name_color,
|
||||
"patron": v.patron,
|
||||
"text": text,
|
||||
"text_censored": censor_slurs_profanities(text, 'chat'),
|
||||
"text_censored": censor_slurs_profanities(text, 'chat', True),
|
||||
"text_html": text_html,
|
||||
"text_html_censored": censor_slurs_profanities(text_html, 'chat'),
|
||||
"time": int(time.time()),
|
||||
|
|
Loading…
Reference in New Issue