Laravel HTML 净化器

标签 laravel htmlpurifier

我在使 HTMLPurifier bundle 正常工作时遇到问题。我安装的是这样的:

php artisan bundle:install Sanitizer

然后我编辑了 application/bundles.php

'sanitize' => array('auto' => true),

当我使用它时:

$clean_output = Sanitize::purify($bad_input);

我收到未处理的异常:未找到“Sanitize”类

我还注意到,当我尝试:php artisan bundle:upgrade Sanitize时, 我收到一条错误消息,提示 bundle 未安装。 我缺少什么? 非常感谢任何帮助。

最佳答案

这个 bundle 的设置非常糟糕,尤其是不同的命名和大小写。通常, bundle 全面使用标准名称。这里发生的情况是,当您安装 bundle 时,它实际上是将其安装到bundles/laravel-htmlpurifier。您在 bundles.php 文件中定义的内容期望将其安装在 bundles/sanitize 处。

您有两个选择。

选项 1

laravel-htmlpurifier 目录重命名为 sanitize

选项 2

bundles.php 文件中设置 location 键。

'sanitize' => array('auto' => true, 'location' => 'laravel-htmlpurifier')

这也应该可以解决您遇到的升级问题。您实际上不必这样做,因为通常包作者有责任确保所有内容的命名正确且一致。

关于Laravel HTML 净化器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16370468/

相关文章:

php - Laravel 无法删除或更新父行 : a foreign key constraint fails

php - HTML Purifier - 转义不允许的标签而不是剥离

security - 如何防止 XSS 格式错误的标签

php - HTML净化器Symfony2.3

Laravel:从队列中删除作业

javascript - Laravel 5.6 - 使用 laravel-mix 拆分 vuejs 代码

laravel - 如何更新 Lumen 中的字段

php - 在某些特殊情况下不会插入数据?

php - HTML Purifier - 允许链接?

php - 使用 Laravel 在 Json 列中搜索