maniruzzaman / sanitizer
一个PHP包,可以对您的所有输入和HTML进行清理
0.0.7
2021-11-06 13:03 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-09-16 07:42:28 UTC
README
清理并转义PHP应用程序中的每个值。
此解决方案将使PHP开发者的生活变得简单,非常简单,开发者可以快速轻松地创建一个安全的应用程序。
让我们看看它的内部结构。
需求
- PHP: 7.1 或更高版本
- PHP Unit (开发中) 7
最新版本
0.0.7
如何安装
composer require maniruzzaman/sanitizer
文档
实例化和加载。
// at top of the class autoload use Maniruzzaman\Sanitizer\Sanitize; // instantiate anywhere if needed $sanitize = new Sanitize();
清理文本
示例 1:使用脚本清理文本
$string = 'Text with script <script>alert("you are hacked...")</script>'; Sanitize::text($string); #Output: Text with issuealert("you are hacked...")
示例 2:使用HTML文本清理文本
$string = 'Text with script <strong>This is strong text</strong>'; Sanitize::text($string); #Output: Text with script This is strong text
清理属性
示例 3:清理属性以过滤掉不必要的字符串
$string = 'https://devsenv.com<script>welcome</script>'; $sanitize = new Sanitize(); $sanitize->attr($string); #Output: https:://devsenv.com
更多即将到来...
测试
我们使用 PHPUnit 测试我们的代码。
检查是否所有测试用例都通过。您可以检查我们的测试用例以查看清理器的实现。
// For full directory phpunit tests // For specific file test phpunit tests/SanitizeTest.php
发行说明
版本 0.0.7
- [增强] 为 text() 辅助函数的 sanitize 功能添加了单元测试。
- [增强] 添加了一些安全和资金链接。
版本 0.0.6
- [增强] 更新了一些 doc-block。
- [增强] 重新构建了一些代码库。
- [增强] 更新了最低PHP版本要求。
- [增强] 为开发包添加了PHP Unit测试支持。
版本 0.0.5
- 修复了一些与文档相关的自动加载问题。
版本 0.0.4
- 修复了自动加载函数。
版本 0.0.3
- 移除了一些未使用的自动加载依赖项。
版本 0.0.2
- 添加了
Url
清理。
版本 0.0.1
- 发布了一些简单的转义函数。
- 添加了
text
清理。 - 添加了
attribute
清理。
许可证
该库是开源软件,许可协议为 MIT 协议。
支持
您想支持我买杯咖啡吗?请成为我的 Patreon 之一 - https://www.patreon.com/maniruzzaman