使"<“到"\<”和">“到">”的要点是避免下面的内联脚本:
<script>
var foo = "</script><script>alert('bug');</script><script>"; // the value of foo is generated from server
</script>foo的字符串值是从服务器端生成的。因此,我们计划将"<“改为"\<”,将">“更改为">”。(我知道有人认为">“应该转到"& gt;",但在这种情况下没有考虑到这一点。)
因此,预期结果是:
<script>
var foo = "\</script\>\<script\>alert('bug');\</script\>\<script\>"; // the value of foo is generated from server
</script>对于IE7/8和Firefox,HTML呈现引擎不会将javascript字符串中的\</strong>作为<strong></strong>标记,而JavaScript引擎仍然将其视为字符串"“。但是,我不确定是否所有浏览器都这样对待">“和"\<”。这种标准适用于所有浏览器吗?</div><div></div>
发布于 2009-04-30 02:38:35
不,您最好的选择是使用>和<分别用于大于和小于符号。
所以你会想要这样的东西
var foo = "</script><script>alert('bug');</script><script>";https://stackoverflow.com/questions/805143
复制相似问题