From 460b6e653cf0c28b65acdb7df35c2f51475ee020 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 28 Sep 2021 05:50:38 +0200 Subject: [PATCH] [MIRROR] Fix word bounds on filters, where they would only be applied at the beginning [MDB IGNORE] (#8444) * Fix word bounds on filters, where they would only be applied at the beginning (#61714) * Fix word bounds on filters, where they would only be applied at the beginning Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com> --- code/controllers/configuration/configuration.dm | 2 +- code/modules/unit_tests/chat_filter.dm | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/controllers/configuration/configuration.dm b/code/controllers/configuration/configuration.dm index 685dd900b96..16411397e16 100644 --- a/code/controllers/configuration/configuration.dm +++ b/code/controllers/configuration/configuration.dm @@ -427,7 +427,7 @@ Example config: to_join_on_whitespace_splits += REGEX_QUOTE(banned_word) var/whitespace_split = @"(?:(?:^|\s+)(" + jointext(to_join_on_whitespace_splits, "|") + @")(?:$|\s+))" - var/word_bounds = @"(\b(" + jointext(to_join_on_word_bounds, "|") + "))" + var/word_bounds = @"(\b(" + jointext(to_join_on_word_bounds, "|") + @")\b)" return regex("([whitespace_split]|[word_bounds])", "i") //Message admins when you can. diff --git a/code/modules/unit_tests/chat_filter.dm b/code/modules/unit_tests/chat_filter.dm index b8fbaa16a31..ac59328a2f3 100644 --- a/code/modules/unit_tests/chat_filter.dm +++ b/code/modules/unit_tests/chat_filter.dm @@ -20,6 +20,14 @@ null, ) + test_filter( + "these words have filtered words in them: ablockedinic blockedinicbbbb aablockedinicbb", + null, + null, + null, + null, + ) + test_filter( "<(0_0<) <(0_0)> (>0_0)> KIRBY DANCE!!!", "<(0_0<)",