snipe / banbuilder
一个用于轻松处理PHP项目中粗话过滤的库。
2.3.0
2018-08-30 22:45 UTC
Requires
- php: >=5.6.0
Requires (Dev)
- phpunit/phpunit: ^5.7.0
README
BanBuilder是一个用于粗话过滤的PHP包。PHP脚本使用正则表达式智能地寻找“leet speak”风格的数字或符号替换。
安装
要安装BanBuilder,只需将其包含在项目的composer.json
中。
"snipe/banbuilder": "dev-master",
此包工作不需要任何其他依赖项。
用法
有关完整使用说明,请参阅官方包网站。
摘要
简而言之,此代码将一个包含不良词的数组与一个包含常见过滤规避策略的数组进行比较。然后它通过将正则表达式参数插入不良词数组来进行字符串替换,然后评估输入字符串是否包含已扩展的禁止词列表。
因此,在你的不良词数组中,你可能会有
[0] => 'ass'
preg_replace
函数将所有可能的怪异字母替换为正则表达式模式(而不是将变体添加到数组末尾),因此数组中的'ass'在preg_replace
检查匹配之前变成了这样
[0] => /(a|a\.|a\-|4|@|Á|á|À|Â|à|Â|â|Ä|ä|Ã|ã|Å|å|α)(s|s\.|s\-|5|\$|§)(s|s\.|s\-|5|\$|§)/i
这意味着一个单词可以有零个、一个或任何种类的leet替换,它仍然会触发警报。leet过滤的一部分包括删除字母连字符和字母点。
这意味着以下所有都评估为“bitch”
- B1tch
- bi7tch
- b.i.t.c.h.
- b-i-t-c-h
- b.1.t.c.h.
- ßitch
- 等等...
测试
要从包目录中运行此包的单元测试,只需运行vendor/bin/phpunit
。
许可证
Copyright (C) 2013 Alison Gianotto - snipe@snipe.net
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://gnu.ac.cn/licenses/>.