增加敏感词检测
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.onekeycall.videotablet.config;
|
||||
|
||||
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
|
||||
import com.github.houbb.sensitive.word.support.ignore.SensitiveWordCharIgnores;
|
||||
import com.github.houbb.sensitive.word.support.resultcondition.WordResultConditions;
|
||||
import com.github.houbb.sensitive.word.support.tag.WordTags;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 配置类,用于设置敏感词过滤器的自定义过滤策略
|
||||
* 更多配置见 https://github.com/houbb/sensitive-word
|
||||
*/
|
||||
@Configuration
|
||||
public class SensitiveWordConfig {
|
||||
|
||||
/**
|
||||
* 初始化引导类
|
||||
* @return 初始化引导类
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Bean
|
||||
public SensitiveWordBs sensitiveWordBs() {
|
||||
SensitiveWordBs wordBs = SensitiveWordBs.newInstance()
|
||||
.ignoreCase(true) // 忽略大小写,默认值为true
|
||||
.ignoreWidth(true) // 忽略半角圆角,默认值为true
|
||||
.ignoreNumStyle(true) // 忽略数字的写法,默认值为true
|
||||
.ignoreChineseStyle(true) // 忽略中文的书写格式,默认值为true
|
||||
.ignoreEnglishStyle(true) // 忽略英文的书写格式,默认值为true
|
||||
.ignoreRepeat(false) // 忽略重复词,默认值为false
|
||||
.enableNumCheck(false) // 是否启用数字检测,默认值为false
|
||||
.enableEmailCheck(false) // 是有启用邮箱检测,默认值为false
|
||||
.enableUrlCheck(false) // 是否启用链接检测,默认值为false
|
||||
.enableIpv4Check(false) // 是否启用IPv4检测,默认值为false
|
||||
.enableWordCheck(true) // 是否启用敏感单词检测,默认值为true
|
||||
.numCheckLen(8) // 数字检测,自定义指定长度,默认值为8
|
||||
.wordTag(WordTags.none()) // 词对应的标签,默认值为none
|
||||
.charIgnore(SensitiveWordCharIgnores.defaults()) // 忽略的字符,默认值为none
|
||||
.wordResultCondition(WordResultConditions.alwaysTrue()) // 针对匹配的敏感词额外加工,比如可以限制英文单词必须全匹配,默认恒为真
|
||||
.init();
|
||||
|
||||
return wordBs;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user