diff --git a/files/helpers/slurs_and_profanities.py b/files/helpers/slurs_and_profanities.py
index 5251e98a7c..6d60ed56d8 100644
--- a/files/helpers/slurs_and_profanities.py
+++ b/files/helpers/slurs_and_profanities.py
@@ -1,5 +1,6 @@
import re
from .config.const import *
+from .regex import NOT_IN_CODE_OR_LINKS
tranny = f''
trannie = f'
'
@@ -106,8 +107,9 @@ PROFANITIES = {
slur_single_words = "|".join([slur.lower() for slur in SLURS.keys()])
profanity_single_words = "|".join([profanity.lower() for profanity in PROFANITIES.keys()])
-slur_regex = re.compile(f"<[^>]*>|{slur_single_words}", flags=re.I|re.A)
-profanity_regex = re.compile(f"<[^>]*>|{profanity_single_words}", flags=re.I|re.A)
+
+slur_regex = re.compile(f"(<[^>]*>|{slur_single_words})" + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A)
+profanity_regex = re.compile(f"(<[^>]*>|{profanity_single_words})" + NOT_IN_CODE_OR_LINKS, flags=re.I|re.A)
SLURS_FOR_REPLACING = {}
for k, val in SLURS.items():
@@ -150,9 +152,6 @@ def sub_matcher_profanities(match):
def censor_slurs_profanities(body, logged_user, is_plain=False):
if not body: return ""
- if '
' in body or '' in body:
- return body
-
if not logged_user or logged_user == 'chat' or logged_user.slurreplacer:
body = slur_regex.sub(sub_matcher_slurs, body)