fixed dfa bug
This commit is contained in:
parent
5a198f8f0b
commit
b4b0d624a6
1
catch/system/request/sensitiveWord/UpdateRequest.php
Normal file
1
catch/system/request/sensitiveWord/UpdateRequest.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?php
|
@ -86,6 +86,7 @@ class Trie
|
|||||||
}
|
}
|
||||||
$node = $trieTree[$words[$start]];
|
$node = $trieTree[$words[$start]];
|
||||||
$this->sensitiveWord = $words[$start];
|
$this->sensitiveWord = $words[$start];
|
||||||
|
// 从敏感词开始查找内容中是否又符合的
|
||||||
for ($i = $start+1; $i< $len; $i++) {
|
for ($i = $start+1; $i< $len; $i++) {
|
||||||
$node = $node[$words[$i]] ?? null;
|
$node = $node[$words[$i]] ?? null;
|
||||||
$this->sensitiveWord .= $words[$i];
|
$this->sensitiveWord .= $words[$i];
|
||||||
@ -103,6 +104,13 @@ class Trie
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 防止内容比敏感词短 导致验证过去
|
||||||
|
// 使用敏感词【傻子】校验【傻】这个词
|
||||||
|
// 会提取【傻】
|
||||||
|
// 再次判断是否是尾部
|
||||||
|
if (!isset($node['end'])) {
|
||||||
|
$this->sensitiveWord = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $all ? $this->sensitiveWords : $this->sensitiveWord;
|
return $all ? $this->sensitiveWords : $this->sensitiveWord;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user