mirror of
https://github.com/houbb/sensitive-word.git
synced 2026-03-22 08:27:36 +08:00
release branch 0.22.0
This commit is contained in:
@@ -368,3 +368,9 @@
|
||||
|:---|:-----|------------------------------------|:-------------------|:------------------------------------------------------|
|
||||
| 1 | O | 优化白名单的匹配策略,避免长白名单时,匹配到短的黑名单,不符合预期。 | 2024-9-18 21:39:40 | https://github.com/houbb/sensitive-word/issues/76 +19 |
|
||||
| 2 | A | 白名单支持单个编辑 | 2024-9-18 21:39:40 | 避免全量初始化 |
|
||||
|
||||
# release_0.22.0
|
||||
|
||||
| 序号 | 变更类型 | 说明 | 时间 | 备注 |
|
||||
|:---|:-----|----------|:--------------------|:------------------------------------------------------|
|
||||
| 1 | F | 修正数字匹配问题 | 2024-11-10 22:43:08 | https://github.com/houbb/sensitive-word/issues/84 |
|
||||
|
||||
15
README.md
15
README.md
@@ -54,21 +54,16 @@
|
||||
|
||||
[CHANGE_LOG.md](https://github.com/houbb/sensitive-word/blob/master/CHANGE_LOG.md)
|
||||
|
||||
### V0.19.0
|
||||
|
||||
- 针对单个词的新增/删除,无需全量初始化
|
||||
- 新增 allow/deny 空实现
|
||||
|
||||
### V0.20.0
|
||||
|
||||
- 新增数字+英文的全词匹配实现
|
||||
|
||||
### V0.21.0
|
||||
|
||||
- 修正白名单较长,包含了黑名单,导致白名单不符合预期的场景。
|
||||
|
||||
- 新增了白名单单个的编辑操作
|
||||
|
||||
### V0.22.0
|
||||
|
||||
- 修正单个敏感词修改时,对应的格式处理问题
|
||||
|
||||
## 更多资料
|
||||
|
||||
### 敏感词控台
|
||||
@@ -99,7 +94,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.21.0</version>
|
||||
<version>0.22.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>sensitive-word</artifactId>
|
||||
<version>0.21.0</version>
|
||||
<version>0.22.0</version>
|
||||
|
||||
<properties>
|
||||
<!--============================== All Plugins START ==============================-->
|
||||
|
||||
@@ -10,9 +10,9 @@ ECHO "============================= RELEASE START..."
|
||||
|
||||
:: 版本号信息(需要手动指定)
|
||||
:::: 旧版本名称
|
||||
SET version=0.21.0
|
||||
SET version=0.22.0
|
||||
:::: 新版本名称
|
||||
SET newVersion=0.22.0
|
||||
SET newVersion=0.23.0
|
||||
:::: 组织名称
|
||||
SET groupName=com.github.houbb
|
||||
:::: 项目名称
|
||||
|
||||
@@ -639,7 +639,11 @@ public class SensitiveWordBs implements ISensitiveWordDestroy {
|
||||
if(CollectionUtil.isEmpty(collection)) {
|
||||
return;
|
||||
}
|
||||
for(String word : collection) {
|
||||
// fixed https://github.com/houbb/sensitive-word/issues/84
|
||||
// 主要原因是二者没有保持一致,初始化的数据和插入的数据没有做相同的格式化
|
||||
List<String> formatList = InnerWordFormatUtils.formatWordList(collection, context);
|
||||
|
||||
for(String word : formatList) {
|
||||
this.wordData.removeWord(word);
|
||||
}
|
||||
}
|
||||
@@ -650,7 +654,11 @@ public class SensitiveWordBs implements ISensitiveWordDestroy {
|
||||
* @since 0.19.0
|
||||
*/
|
||||
public void addWord(Collection<String> collection) {
|
||||
this.wordData.addWord(collection);
|
||||
// fixed https://github.com/houbb/sensitive-word/issues/84
|
||||
// 主要原因是二者没有保持一致,初始化的数据和插入的数据没有做相同的格式化
|
||||
// 正常字典并没有这个问题
|
||||
List<String> formatAllowList = InnerWordFormatUtils.formatWordList(collection, context);
|
||||
this.wordData.addWord(formatAllowList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -690,7 +698,11 @@ public class SensitiveWordBs implements ISensitiveWordDestroy {
|
||||
if(CollectionUtil.isEmpty(collection)) {
|
||||
return;
|
||||
}
|
||||
for(String word : collection) {
|
||||
// fixed https://github.com/houbb/sensitive-word/issues/84
|
||||
// 主要原因是二者没有保持一致,初始化的数据和插入的数据没有做相同的格式化
|
||||
List<String> formatList = InnerWordFormatUtils.formatWordList(collection, context);
|
||||
|
||||
for(String word : formatList) {
|
||||
this.wordDataAllow.removeWord(word);
|
||||
}
|
||||
}
|
||||
@@ -700,7 +712,11 @@ public class SensitiveWordBs implements ISensitiveWordDestroy {
|
||||
* @since 0.21.0
|
||||
*/
|
||||
public void addWordAllow(Collection<String> collection) {
|
||||
this.wordDataAllow.addWord(collection);
|
||||
// fixed https://github.com/houbb/sensitive-word/issues/84
|
||||
// 主要原因是二者没有保持一致,初始化的数据和插入的数据没有做相同的格式化
|
||||
List<String> formatList = InnerWordFormatUtils.formatWordList(collection, context);
|
||||
|
||||
this.wordDataAllow.addWord(formatList);
|
||||
}
|
||||
/**
|
||||
* 新增敏感词白名单
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.github.houbb.sensitive.word.support.data;
|
||||
|
||||
import com.github.houbb.heaven.annotation.ThreadSafe;
|
||||
import com.github.houbb.heaven.util.lang.ObjectUtil;
|
||||
import com.github.houbb.heaven.util.lang.StringUtil;
|
||||
import com.github.houbb.sensitive.word.api.IWordContext;
|
||||
|
||||
@@ -78,10 +78,10 @@ public final class InnerWordFormatUtils {
|
||||
* @return 结果
|
||||
* @since 0。3.0
|
||||
*/
|
||||
public static List<String> formatWordList(List<String> list,
|
||||
public static List<String> formatWordList(Collection<String> list,
|
||||
final IWordContext context) {
|
||||
if(CollectionUtil.isEmpty(list)) {
|
||||
return list;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<String> resultList = new ArrayList<>(list.size());
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.github.houbb.sensitive.word.bugs.b54;
|
||||
|
||||
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
|
||||
import com.github.houbb.sensitive.word.support.allow.WordAllows;
|
||||
import com.github.houbb.sensitive.word.support.deny.WordDenys;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Bug84Test {
|
||||
|
||||
@Test
|
||||
public void bug84IgnoreNumberStyleTrueTest() {
|
||||
// 例如,敏感词“下三滥”。通过
|
||||
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
|
||||
.wordAllow(WordAllows.empty())
|
||||
.wordDeny(WordDenys.empty())
|
||||
// 因为这里默认是 true
|
||||
.ignoreNumStyle(true)
|
||||
.init();
|
||||
sensitiveWordBs.addWord("下三滥");
|
||||
String result = sensitiveWordBs.findFirst("花豹用下三滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertEquals("下三滥", result);
|
||||
|
||||
String result2 = sensitiveWordBs.findFirst("花豹用下3滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertEquals("下3滥", result2);
|
||||
|
||||
// 移除
|
||||
sensitiveWordBs.removeWord("下三滥");
|
||||
String result3 = sensitiveWordBs.findFirst("花豹用下三滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result3);
|
||||
|
||||
String result4 = sensitiveWordBs.findFirst("花豹用下3滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug84IgnoreNumberStyleTrueTest2() {
|
||||
// 例如,敏感词“下三滥”。通过
|
||||
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
|
||||
.wordAllow(WordAllows.empty())
|
||||
.wordDeny(WordDenys.empty())
|
||||
// 因为这里默认是 true
|
||||
.ignoreNumStyle(true)
|
||||
.init();
|
||||
sensitiveWordBs.addWord("下3滥");
|
||||
String result = sensitiveWordBs.findFirst("花豹用下三滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertEquals("下三滥", result);
|
||||
|
||||
String result2 = sensitiveWordBs.findFirst("花豹用下3滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertEquals("下3滥", result2);
|
||||
|
||||
// 移除
|
||||
sensitiveWordBs.removeWord("下3滥");
|
||||
String result3 = sensitiveWordBs.findFirst("花豹用下三滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result3);
|
||||
|
||||
String result4 = sensitiveWordBs.findFirst("花豹用下3滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bug84IgnoreNumberStyleFalseTest() {
|
||||
// 例如,敏感词“下三滥”。通过
|
||||
SensitiveWordBs sensitiveWordBs = SensitiveWordBs.newInstance()
|
||||
.wordAllow(WordAllows.empty())
|
||||
.wordDeny(WordDenys.empty())
|
||||
// 因为这里默认是 true
|
||||
.ignoreNumStyle(false)
|
||||
.init();
|
||||
sensitiveWordBs.addWord("下三滥");
|
||||
String result = sensitiveWordBs.findFirst("花豹用下三滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertEquals("下三滥", result);
|
||||
|
||||
String result2 = sensitiveWordBs.findFirst("花豹用下3滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result2);
|
||||
|
||||
// 移除
|
||||
sensitiveWordBs.removeWord("下三滥");
|
||||
String result3 = sensitiveWordBs.findFirst("花豹用下三滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result3);
|
||||
|
||||
String result4 = sensitiveWordBs.findFirst("花豹用下3滥招式对付疣猪,没想到疣猪居然也有绝招");
|
||||
Assert.assertNull(result4);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user