【问题标题】:Java - XSS - HTML encoding - Character entity reference vs. Numeric entity referenceJava - XSS - HTML 编码 - 字符实体引用与数字实体引用
【发布时间】: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>

被编码为

  &lt;script&gt;

但本文中包含的 Java 代码示例使用数字引用编码,即

<script></script>

被编码为

 &#60;script&#62;&#60;&#47;script&#62;

是否有理由使用字符引用而不是实体引用?哪个最好,为什么?

【问题讨论】:

    标签: java html encoding xss


    【解决方案1】:

    就保护自己免受 XSS 的影响而言,它们是相同的。唯一真正的实际区别是可读性和大小。

    【讨论】:

      猜你喜欢
      • 2012-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 1970-01-01
      • 1970-01-01
      • 2017-09-22
      相关资源
      最近更新 更多