Skip to content

Commit

Permalink
Fix word bounds on filters, where they would only be applied at the b…
Browse files Browse the repository at this point in the history
…eginning (tgstation#61714)
  • Loading branch information
Mothblocks committed Sep 28, 2021
1 parent 563cb1d commit 1f000ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,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.
Expand Down
8 changes: 8 additions & 0 deletions code/modules/unit_tests/chat_filter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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<)",
Expand Down

0 comments on commit 1f000ba

Please sign in to comment.