accentinteractive/disallowlister
Composer 安装命令:
composer require accentinteractive/disallowlister
包简介
Test a string against a disallowlist. Useful for user forms and such.
README 文档
README
This little package tests a string against a disallowlist.
If you are looking for a Laravel-specific implementation, see https://github.com/accentinteractive/laravel-disallowlister
The isDisallowed() method can use wildcards, like *.
Under the hood, accentinteractive/disallowtester uses fnmatch(), so you can use the same wildcards as in that php function (the globbing wildcard patterns):
-
*sex*disallows sex, sexuality and bisexual. -
cycle*disallows cycle and cycles, but not bicycle. -
m[o,u]mdisallows mom and mum, but allows mam. -
m?ndisallows man and men, but allows moon.
Installation
You can install the package via composer:
composer require accentinteractive/disallowlister
Usage
Setting the disallowlist
You can pass the disallowlist in the constructor or via other methods.
// Pass the disallowlist in the constructor $disallowLister = new DisallowLister(['foo']); // ['foo'] // Set the disallowlist in the setter method $disallowLister->setDisallowList(['bar']); // ['bar'] // Add an item to the disallowlist $disallowLister->add('baz'); // ['bar', 'baz'] // Add multiple items to the disallowlist $disallowLister->add(['bat', 'fiz']); // ['bar', 'baz', 'bat', 'fiz'] // Remove an item from the disallowlist $disallowLister->remove('fiz'); // ['bar', 'baz', 'bat'] // Remove multiple items from the disallowlist $disallowLister->remove(['baz', 'bat']); // ['bar']
Checking data against the disallowlist
## Literal string $disallowLister = new DisallowLister(['bar', 'foo']); $disallowLister->isDisallowed('bar'); // Returns true $disallowLister->isDisallowed('bars'); // Returns false ## Wildcards // Under the hood, `accentinteractive/disallowtester` // uses `fnmatch()`, so you can use the same // wildcards as in that php function (the // globbing wildcard patterns): (new DisallowLister(['b?r']))->isDisallowed('bar'); // Returns true (new DisallowLister(['m[o,u]m']))->isDisallowed('mom'); // Returns true (new DisallowLister(['*bar*']))->isDisallowed('I like crowbars'); // Returns true
Case sensitivity
// By default, matching is not case sensitive (new DisallowLister(['bar']))->isDisallowed('BAR'); // Returns true // To set case sensitive matching (new DisallowLister(['bar']))->caseSensitive(true)->isDisallowed('BAR'); // Returns false
Whole word checking
// By default the entire string is checked. (new DisallowLister())->setDisallowList(['bar'])->isDisallowed('My favorite bar'); // Returns false // Check word for word. (new DisallowLister())->setDisallowList(['bar'])->setWordForWord(true)->isDisallowed('My favorite bar'); // Returns true
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email joost@accentinteractive.nl instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
accentinteractive/disallowlister 适用场景与选型建议
accentinteractive/disallowlister 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「accentinteractive」 「disallowlister」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 accentinteractive/disallowlister 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 accentinteractive/disallowlister 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 accentinteractive/disallowlister 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Keep your laravel logs small and tidy.
Block bad bots and users that visit certain (exploit) urls for a set amount of time.
Keep your laravel logs small and tidy.
Azure AD SSO (Single Sign On) login management for Laravel.
Do not process URLs with a extensions like .jpg, .png et cetera.
Validate data against one or multiple disallowlists, using the built-in Laravel validator or by calling the facade directly. Supports wildcards.
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-17