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.
是否有必要过滤/转义不安全的变量<title>或其他标签<head>以防止 XSS?
<title>
<head>
严格来说,绝对htmlspecialchars()有必要对您从 PHP 输出到网页的所有内容进行处理。
htmlspecialchars()
如果您发现这会产生错误的结果(即 HTML 代码由于双重编码而显示在浏览器中),您已经在您的应用程序中发现了设计缺陷。
如果人们坚持这个简单的规则,XSS 就不会成为问题。
是的。您应该始终htmlspecialchars对可能包含 HTML 特殊字符的值使用该函数。
htmlspecialchars