第58批续29:黑名单前2字符匹配(问题2)
Check Source / check (push) Successful in 4s
Auto Release / build (push) Successful in 2m56s
Simple Test / test (push) Successful in 1s
Test Env / test (push) Successful in 2s

- AIChatManager.isBlacklisted 增加前2字符匹配:
  黑名单词'测试一下'的前2字符'测试'出现在消息'让我们来做个测试' → 拦截
- 保留完整包含匹配 + 新增前缀匹配,双重判断防漏
This commit is contained in:
youpaishidifu
2026-10-29 11:59:19 +08:00
parent 4b92969c64
commit 56c4069173
+6 -3
View File
@@ -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;
} }