HTML 转义的最低安全级别是多少?
假设我有一些任意文本,我们将其称为 TEXT。如果我用 <
替换 <
的所有实例,用 &< 替换
&
的所有实例/code>,并将 TEXT 替换为 HTML 文档,如下所示:
<div>TEXT</div>
那么我是否已尽到转义特殊字符的职责?
Assume I have some arbitrary text which we will call TEXT. If I replace all instances of <
with <
, and all instances of &
with &
, and substitute TEXT into an HTML document like so:
<div>TEXT</div>
Then have I done my duty as far as escaping special characters goes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
差不多,是的。
如果有可能最终出现在属性字符串中,转义引号也很有用。
Pretty much, yeah.
Escaping quotes can be useful as well, if there's a chance it might end up in an attribute string.