From 2298bdbce09aa7f0dbc5ce5cbef5949fa13eea0d Mon Sep 17 00:00:00 2001 From: Undearius Date: Mon, 31 Mar 2025 21:37:52 -0400 Subject: [PATCH] Refined slur_regex pattern (#5567) Removed duplicate match group and adjusted the pattern to narrow the match closer to the naughty word. --- crates/utils/src/utils/slurs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/utils/src/utils/slurs.rs b/crates/utils/src/utils/slurs.rs index 6d594d129..9a7229422 100644 --- a/crates/utils/src/utils/slurs.rs +++ b/crates/utils/src/utils/slurs.rs @@ -52,7 +52,7 @@ mod test { #[test] fn test_slur_filter() -> LemmyResult<()> { - let slur_regex = RegexBuilder::new(r"(fag(g|got|tard)?\b|cock\s?sucker(s|ing)?|ni((g{2,}|q)+|[gq]{2,})[e3r]+(s|z)?|mudslime?s?|kikes?|\bspi(c|k)s?\b|\bchinks?|gooks?|bitch(es|ing|y)?|whor(es?|ing)|\btr(a|@)nn?(y|ies?)|\b(b|re|r)tard(ed)?s?)").case_insensitive(true).build()?; + let slur_regex = RegexBuilder::new(r"(fag(g|got|tard)?\b|cock\s?sucker(s|ing)?|ni[gq]{2}[e3]?r[sz]?|mudslime?s?|kikes?|\bspi(c|k)s?\b|\bchinks?|gooks?|bitch(es|ing|y)?|whor(es?|ing)|\btr(a|@)nn?(y|ies?)|\b(b|re|r)tard(ed)?s?)").case_insensitive(true).build()?; let test = "faggot test kike tranny cocksucker retardeds. Capitalized Niggerz. This is a bunch of other safe text."; let slur_free = "No slurs here";