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:
parent
6e6bf612dc
commit
ace019d7d9
|
@ -26,6 +26,7 @@ package net.socialgamer.cah.util;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
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...
|
// TODO keep track of how much someone does this and perma-shadowban them...
|
||||||
for (final String banned : getShadowbanCharacters()) {
|
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(
|
LOG.info(String.format(
|
||||||
"Dropping message '%s' from user %s (%s); contains banned string %s.", message,
|
"Dropping message '%s' from user %s (%s); contains banned string %s.", message,
|
||||||
user.getNickname(), user.getHostname(), banned));
|
user.getNickname(), user.getHostname(), banned));
|
||||||
|
|
|
@ -28,7 +28,8 @@ import java.util.Set;
|
||||||
public interface ShadowBannedStringProvider {
|
public interface ShadowBannedStringProvider {
|
||||||
/**
|
/**
|
||||||
* A message that contains any string in this set should be silently dropped: not forwarded to any
|
* 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();
|
Set<String> getShadowBannedStrings();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue