Clarify that shadowbanned strings should be provided in lower-case.

And also make that check essentially be case-insentive as well as case-sensitive (check them both).
This commit is contained in:
Andy Janata 2018-03-26 09:58:00 -07:00
parent 6e6bf612dc
commit ace019d7d9
2 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,7 @@ package net.socialgamer.cah.util;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@ -152,9 +153,12 @@ public class ChatFilter {
}
}
final String messageLower = message.toLowerCase(Locale.ENGLISH);
// TODO keep track of how much someone does this and perma-shadowban them...
for (final String banned : getShadowbanCharacters()) {
if (message.contains(banned)) {
// assume that the banned strings are already lowercase
// check both ways in case it decides lowercase of some unicode is not what we want though
if (message.contains(banned) || messageLower.contains(banned)) {
LOG.info(String.format(
"Dropping message '%s' from user %s (%s); contains banned string %s.", message,
user.getNickname(), user.getHostname(), banned));

View File

@ -28,7 +28,8 @@ import java.util.Set;
public interface ShadowBannedStringProvider {
/**
* A message that contains any string in this set should be silently dropped: not forwarded to any
* other user nor inform the originating user that the message was dropped.
* other user nor inform the originating user that the message was dropped. These should all be in
* lower-case unless the case matters for what they look like.
*/
Set<String> getShadowBannedStrings();
}