Repository navigation
Match profanity words case-insensitively and across punctuation - #382
Merged
Cannonb4ll merged 1 commit intoOct 7, 2026
Merged
Conversation
ProfanityCheck split content on single spaces and compared each piece with a case-sensitive in_array, so "Fuck", "fuck!", newline-separated words and the default multi-word entry "screw you" were never caught. Match each configured entry as a whole word or phrase, ignoring case and allowing any whitespace between the words of a phrase. Words that only contain an entry (e.g. "Dickens") are still allowed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ProfanityCheck split the content on single spaces and compared each piece with a case-sensitive in_array. Because of that, "Fuck", a word with punctuation right after it, a word on a new line and the default multi-word entry "screw you" weren't caught.
Each configured entry is now matched as a whole word or phrase, ignoring case. Any whitespace is allowed between the words of a phrase. Words that only contain an entry, like "Dickens" or "class", are still allowed. Empty entries are ignored.
Note that matching is now case-insensitive, so an entry like "dick" also blocks "Dick".
Added a unit test for the rule. It fails on the current main and passes with this change.