diff --git a/files/classes/comment.py b/files/classes/comment.py index 8068b5db7..f502b918a 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -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 diff --git a/files/classes/hats.py b/files/classes/hats.py index b0ddd5b6d..746ffc73f 100644 --- a/files/classes/hats.py +++ b/files/classes/hats.py @@ -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 diff --git a/files/classes/post.py b/files/classes/post.py index bc23555ee..6e1b1370a 100644 --- a/files/classes/post.py +++ b/files/classes/post.py @@ -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 diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index cd343360f..3598b4777 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -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] diff --git a/files/helpers/slurs_and_profanities.py b/files/helpers/slurs_and_profanities.py index 37cd3ef33..ce6ccb74a 100644 --- a/files/helpers/slurs_and_profanities.py +++ b/files/helpers/slurs_and_profanities.py @@ -5,12 +5,6 @@ tranny = f':marseytrain:' troon = f':marseytrain2:' -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 '
' in body or '' 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
diff --git a/files/routes/chat.py b/files/routes/chat.py
index 411d30734..4cee40e6f 100644
--- a/files/routes/chat.py
+++ b/files/routes/chat.py
@@ -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()),