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:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user