Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
真的,我的问题更多地与通过 WYSIWYG 表单组件接受的 html 的服务器端清理有关。现在我倾向于使用 htmlpurifier.org 的库。我在其他地方使用 php strip_tags() 函数。有人有建议/偏好/建议吗?
strip_tags非常脆弱——你还不如什么都不做。HtmlPurifier 可能与 html-cleansing 一样好。如果您真的很重视安全性,您可能应该完全禁止 html 输入,但我意识到这并不总是一种选择。
strip_tags
不要忘记擦掉on*像<p onclick="alert('hi!');">. 这可能会引起一些麻烦。
on*
<p onclick="alert('hi!');">