three72/banbuilder

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

2.2.3 2015-08-26 08:21 UTC

This package is auto-updated.

Last update: 2024-09-26 14:21:24 UTC


README

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

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

安装

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

"three72/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
  • 等等...

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/>.