Add leetspeak normalization for prohibited words

This commit is contained in:
2026-01-20 11:21:30 +01:00
parent 72be64cc8a
commit 25a2d2a5db
+20 -1
View File
@@ -35,6 +35,24 @@ PROHIBITED_WORDS = {
'git', 'shag', 'minge', 'nonce', 'plonker', 'pillock'
}
LEET_MAP = str.maketrans({
"@": "a",
"4": "a",
"8": "b",
"3": "e",
"6": "g",
"9": "g",
"1": "i",
"!": "i",
"|": "l",
"0": "o",
"$": "s",
"5": "s",
"7": "t",
"+": "t",
"2": "z",
})
api = Blueprint("api", __name__, url_prefix="/api")
@@ -45,7 +63,8 @@ def _get_client_ip() -> str:
def _contains_prohibited_word(text: str) -> bool:
lower = text.lower()
return any(w in lower for w in PROHIBITED_WORDS)
normalized = lower.translate(LEET_MAP)
return any(w in lower or w in normalized for w in PROHIBITED_WORDS)
def _get_discord_session() -> requests.Session: