be a bit stricter... i guess i have settled on my level of strictness around names

This commit is contained in:
2025-08-09 18:12:47 +02:00
parent 8a6a35269c
commit 67d861325a
2 changed files with 16 additions and 10 deletions

View File

@@ -400,7 +400,6 @@ yaoi
yellow showers yellow showers
yiffy yiffy
zoophilia zoophilia
🖕
analritter analritter
arsch arsch
arschficker arschficker

View File

@@ -92,18 +92,25 @@ static BAD_WORDS: LazyLock<HashSet<String>> = LazyLock::new(|| {
}); });
fn contains_bad_word(text: &str) -> bool { fn contains_bad_word(text: &str) -> bool {
let cleaned_text: String = text.to_lowercase(); // check parts of string, e.g. ABC_DEF checks both ABC and DEF
let cleaned_text = text.to_lowercase();
for (idx, a) in BAD_WORDS.iter().enumerate() { if cleaned_text
if cleaned_text.trim() == a { .split(|c: char| !c.is_alphabetic())
println!("Text contains {a} on line {idx}"); .any(|part| BAD_WORDS.iter().any(|bad| part == bad))
} {
return true;
} }
BAD_WORDS // check string as a whole, e.g. ABC_DEF checks for ABCDEF
.iter() let cleaned_text: String = text
.any(|bad_word| cleaned_text.trim() == bad_word) .to_lowercase()
.chars()
.filter(|c| c.is_alphabetic())
.collect();
BAD_WORDS.iter().any(|bad_word| &cleaned_text == bad_word)
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::contains_bad_word; use super::contains_bad_word;