第58批续29:黑名单前2字符匹配(问题2)
- AIChatManager.isBlacklisted 增加前2字符匹配: 黑名单词'测试一下'的前2字符'测试'出现在消息'让我们来做个测试' → 拦截 - 保留完整包含匹配 + 新增前缀匹配,双重判断防漏
This commit is contained in:
@@ -1109,9 +1109,12 @@ public class AIChatManager {
|
|||||||
public boolean isBlacklisted(String content) {
|
public boolean isBlacklisted(String content) {
|
||||||
if (content == null || content.isEmpty()) return false;
|
if (content == null || content.isEmpty()) return false;
|
||||||
for (String kw : blacklist) {
|
for (String kw : blacklist) {
|
||||||
if (kw != null && !kw.isEmpty() && content.contains(kw)) {
|
if (kw == null || kw.isEmpty()) continue;
|
||||||
return true;
|
// ★ 第58批续28-问题2:完整包含 → 拦截
|
||||||
}
|
if (content.contains(kw)) return true;
|
||||||
|
// ★ 前缀匹配:黑名单词的前2个字符出现在消息中 → 拦截
|
||||||
|
// "测试一下" 的前2字符 "测试" 出现在 "让我们来做个测试" → 拦截
|
||||||
|
if (kw.length() >= 2 && content.contains(kw.substring(0, 2))) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user