ggiallo28/banbuilder

用于在PHP项目中轻松处理粗口过滤的库。

2.2.3 2015-08-26 08:21 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:25:42 UTC


README

Gitter Build Status Latest Stable Version Total Downloads Latest Unstable Version License

BanBuilder是一个用于粗口过滤的PHP包。PHP脚本使用正则表达式智能地查找类似“leetspeak”风格的数字或符号替换。

安装

要安装BanBuilder,只需将其包含在项目的composer.json中。

"ggiallo28/banbuilder": "master",

此包运行不需要额外的依赖。

使用方法

有关完整的使用说明,请参阅官方包网站

总结

总的来说,此代码将一个包含不良单词的数组与一个包含常见过滤规避策略的数组进行比较。然后它执行字符串替换,将正则表达式参数插入到不良单词数组中,然后评估输入字符串是否包含已扩展的禁止词列表。

因此,在你的不良单词数组中,你可能会有

 [0] => 'ass'

preg_replace函数将所有可能的shenaningan字母替换为正则表达式模式(而不是将变体添加到数组末尾),因此数组中的'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
  • 等等...

Flattr this git repo

测试

要运行此包的单元测试,只需从包目录运行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/>.