【发布时间】:2010-03-05 01:35:32
【问题描述】:
我们一直在寻找对 JSP 页面进行 HTML 编码以应对 XSS 的方法。
OWASP 网站显示How_to_perform_HTML_entity_encoding_in_Java
文章讨论了实体编码“Big 5”即
21 {"#39", new Integer(39)}, // ' - apostrophe
22 {"quot", new Integer(34)}, // " - double-quote
23 {"amp", new Integer(38)}, // & - ampersand
24 {"lt", new Integer(60)}, // < - less-than
25 {"gt", new Integer(62)}, // > - greater-than
即
<script>
被编码为
<script>
但本文中包含的 Java 代码示例使用数字引用编码,即
<script></script>
被编码为
<script></script>
是否有理由使用字符引用而不是实体引用?哪个最好,为什么?
【问题讨论】: