chatfilter: fix matching lt/gt

These are encoded as <lt> and <gt> and so require the patterns to match those, which is unintuitive
This commit is contained in:
Adam
2022-06-06 20:14:26 -04:00
parent 0da4a65ce2
commit 8be3210b87
2 changed files with 14 additions and 1 deletions

View File

@@ -320,7 +320,9 @@ public class ChatFilterPlugin extends Plugin
String censorMessage(final String username, final String message)
{
String strippedMessage = jagexPrintableCharMatcher.retainFrom(message)
.replace('\u00A0', ' ');
.replace('\u00A0', ' ')
.replaceAll("<lt>", "<")
.replaceAll("<gt>", ">");
String strippedAccents = stripAccents(strippedMessage);
assert strippedMessage.length() == strippedAccents.length();

View File

@@ -453,4 +453,15 @@ public class ChatFilterPluginTest
chatFilterPlugin.onScriptCallbackEvent(event);
assertEquals(1, client.getIntStack()[client.getIntStackSize() - 3]); // not filtered
}
@Test
public void testLtGt()
{
when(chatFilterConfig.filteredWords()).thenReturn("f<ilte>r");
chatFilterPlugin.updateFilteredPatterns();
String message = chatFilterPlugin.censorMessage("Adam", "start f<lt>ilte<gt>r end");
assertEquals("start ******** end", message);
}
}