gpt4 book ai didi

PHP 防止 xss

转载 作者:可可西里 更新时间:2023-10-31 22:48:15 31 4
gpt4 key购买 nike

htmlentities 是防止 PHP 中的 XSS 的最佳解决方案吗?我还想允许像 biaimg 这样的简单标签。实现这一点的最佳解决方案是什么?我确实考虑过 bbcode,但发现如果没有正确实现,我也会遇到 XSS 问题。我应该怎么办?欢迎任何优秀的第三方库。

编辑:

我刚刚尝试了 HTML Purifier,但在这种情况下失败了。 Just see this example

最佳答案

为此,我会选择 HTML Purifier ,是的,您也可以在那里指定白名单标签。

HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited,
secure yet permissive whitelist
, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications.

我知道 PHP 语言 中有某些功能,但我更喜欢专用的解决方案。

关于PHP 防止 xss,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5132019/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com