From: Dessalines Date: Mon, 26 Apr 2021 18:18:12 +0000 (-0400) Subject: Fixing regex. Fixes #1593 (#1594) X-Git-Url: http://these/git/%22https:/image.com/%22%7B%7D/static/%7Bicon?a=commitdiff_plain;h=c864dfadf603d9e8c011aa6517d6b8f6460d9b1c;p=lemmy.git Fixing regex. Fixes #1593 (#1594) * Fixing regex. Fixes #1593 * Fixing test --- diff --git a/crates/utils/src/utils.rs b/crates/utils/src/utils.rs index a34d9e30..b8ce4f04 100644 --- a/crates/utils/src/utils.rs +++ b/crates/utils/src/utils.rs @@ -7,7 +7,7 @@ use regex::{Regex, RegexBuilder}; lazy_static! { static ref EMAIL_REGEX: Regex = Regex::new(r"^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$").expect("compile regex"); - static ref SLUR_REGEX: Regex = RegexBuilder::new(r"(fag(g|got|tard)?\b|cock\s?sucker(s|ing)?|\bn(i|1)g(\b|g?(a|er)?(s|z)?)\b|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().expect("compile regex"); + static ref SLUR_REGEX: Regex = RegexBuilder::new(r"(fag(g|got|tard)?\b|cock\s?sucker(s|ing)?|(n|i){1,32}((g{2,32}|q){1,32}|[gq]{2,32})[e3r]{1,32}(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().expect("compile regex"); static ref USERNAME_MATCHES_REGEX: Regex = Regex::new(r"/u/[a-zA-Z][0-9a-zA-Z_]*").expect("compile regex"); // TODO keep this old one, it didn't work with port well tho // static ref MENTIONS_REGEX: Regex = Regex::new(r"@(?P[\w.]+)@(?P[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)").expect("compile regex");