允许使用 HTMLPurifier 嵌入/对象/参数 HTML 标签吗?

发布于 2024-08-03 20:32:01 字数 225 浏览 4 评论 0原文

是否可以使用 HTMLPurifier 允许嵌入、对象和参数 HTML 标签?我试图允许嵌入 YouTube、Vimeo 等视频,但无论我如何尝试,它们总是被删除。我确实知道允许使用这些标签是有风险的。

如果不可能,PHP 还有哪些其他 HTML 过滤选项? Tidy 似乎不是为过滤而设计的……是吗?而且 strip_tags() 没有给我我正在寻找的控制级别 - 例如只允许某些属性。

感谢您的帮助!

Is it possible to allow embed, object, and param HTML tags with HTMLPurifier? I'm trying to allow YouTube, Vimeo, etc. videos to be embedded, but they're always stripped, no matter what I try. I do understand that these are risky tags to allow.

If it's not possible, what other HTML filtering options do I have with PHP? It doesn't seem that Tidy is designed for filtering... is it? And strip_tags() doesn't give me the level of control — such as only allowing certain attributes — that I'm looking for.

Thanks for your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

猥琐帝 2024-08-10 20:32:01

对于较新版本 (4.1+),Filter.YouTube 已弃用。
因此,您应该使用 HTML.SafeObject & Output.FlashCompat

$config->set('HTML.SafeObject', true);
$config->set('Output.FlashCompat', true);
$config->set('HTML.Allowed', 'object[width|height|data],param[name|value]');

但 htmlpurifier 仍然有正确解释 youtube & 的一些问题ETC。
他们的工作地址: http://htmlpurifier.org/phorum/ read.php?5,2239,page=3 所以可能在未来几个月应该最终完成。

For newer versions (4.1+) Filter.YouTube is deprecated.
So instead you should use HTML.SafeObject & Output.FlashCompat

$config->set('HTML.SafeObject', true);
$config->set('Output.FlashCompat', true);
$config->set('HTML.Allowed', 'object[width|height|data],param[name|value]');

but htmlpurifier still have some problems with proper interpretation of youtube & etc.
they work on it at: http://htmlpurifier.org/phorum/read.php?5,2239,page=3 so probably in future months it should be finally done.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文