chat filter: Ignore character accents for matching

This lets plain latin-character filters to match messages with accents
and diacritics which are not easily typed on all keyboard layouts.

Co-authored-by: Jordan Atwood <jordan.atwood423@gmail.com>
This commit is contained in:
Adam
2021-11-13 09:50:23 -05:00
parent 67f7e7f488
commit 1362af414a
2 changed files with 46 additions and 4 deletions

View File

@@ -186,6 +186,36 @@ public class ChatFilterPluginTest
assertNull(chatFilterPlugin.censorMessage("Blue", "hello\u00A0osrs"));
}
@Test
public void testFilterUnicode()
{
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS);
when(chatFilterConfig.filteredWords()).thenReturn("filterme");
chatFilterPlugin.updateFilteredPatterns();
assertEquals("plëäsë ******** plügïn", chatFilterPlugin.censorMessage("Blue", "plëäsë fïltërmë plügïn"));
}
@Test
public void testUnicodeFiltersUnicode()
{
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS);
when(chatFilterConfig.filteredWords()).thenReturn("plëäsë");
chatFilterPlugin.updateFilteredPatterns();
assertEquals("****** fïltërmë plügïn", chatFilterPlugin.censorMessage("Blue", "plëäsë fïltërmë plügïn"));
}
@Test
public void testMixedUnicodeFiltersUnicode()
{
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS);
when(chatFilterConfig.filteredWords()).thenReturn("plëäsë, filterme");
chatFilterPlugin.updateFilteredPatterns();
assertEquals("****** ******** plügïn", chatFilterPlugin.censorMessage("Blue", "plëäsë fïltërmë plügïn"));
}
@Test
public void testMessageFromFriendIsFiltered()
{