Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ContainsProfanity regex CTOR to ignore character casing #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ProfanityFilter.Tests.Unit/ProfanityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -898,5 +898,17 @@ public void ContainsProfanityReturnsTrueWhenProfanityIsADollarDollar()

Assert.IsTrue(result);
}

[TestMethod]
[DataRow("ASS")]
[DataRow("Ass")]
[DataRow("A$$")]
public void ContainsProfanityReturnsTrueForWordsWithUppercase(string input)
{
var filter = new ProfanityFilter();
var result = filter.ContainsProfanity(input);

Assert.IsTrue(result);
}
}
}
2 changes: 1 addition & 1 deletion ProfanityFilter/ProfanityFilter/ProfanityFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public bool ContainsProfanity(string term)
return false;
}

Regex regex = new Regex(string.Format(@"(?:{0})", string.Join("|", potentialProfanities).Replace("$", "\\$"), RegexOptions.IgnoreCase));
Regex regex = new Regex(string.Format(@"(?:{0})", string.Join("|", potentialProfanities).Replace("$", "\\$")), RegexOptions.IgnoreCase);

foreach (Match profanity in regex.Matches(term))
{
Expand Down