From cd2dbfe45354beff050034f532efb0d79f40d52c Mon Sep 17 00:00:00 2001 From: kwwall Date: Mon, 13 Sep 2021 21:50:41 -0400 Subject: [PATCH] Close issue #51. Correct javadoc for Encode class. --- .../main/java/org/owasp/encoder/Encode.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/core/src/main/java/org/owasp/encoder/Encode.java b/core/src/main/java/org/owasp/encoder/Encode.java index 89d7ed9..165635c 100644 --- a/core/src/main/java/org/owasp/encoder/Encode.java +++ b/core/src/main/java/org/owasp/encoder/Encode.java @@ -53,7 +53,12 @@ * *

Please make sure to read and understand the context that the method encodes * for. Encoding for the incorrect context will likely lead to exposing a - * cross-site scripting vulnerability.

+ * cross-site scripting vulnerability. Those new to XSS mitigation may find it + * useful to read the + * + * Cross Site Scripting Prevention Cheat Sheet that is part of the OWASP Cheat Sheet series for background + * material. + *

* * @author Jeff Ichnowski */ @@ -66,7 +71,7 @@ private Encode() {} * this method encodes for both contexts, it may be slightly less * efficient to use this method over the methods targeted towards * the specific contexts ({@link #forHtmlAttribute(String)} and - * {@link #forHtmlContent(String)}. In general this method should + * {@link #forHtmlContent(String)}). In general this method should * be preferred unless you are really concerned with saving a few * bytes or are writing a framework that utilizes this * package.

@@ -155,7 +160,7 @@ public static void forHtml(Writer out, String input) throws IOException { /** *

This method encodes for HTML text content. It does not escape * quotation characters and is thus unsafe for use with - * HTML attributes. Use either forHtml or forHtmlAttribute for those + * HTML attributes. Use either {@link #forHtml(String)} or {@link #forHtmlAttribute(String)} for those * methods.

* * Example JSP Usage @@ -232,7 +237,9 @@ public static void forHtmlContent(Writer out, String input) } /** - *

This method encodes for HTML text attributes.

+ *

This method encodes for HTML text attributes. Do not use for JavaScript event attributes or for attributes + * that are interpreted as a URL. Instead use {@link #forJavaScript(String)} and {@link #forUriComponent(String)} + * respectively for those.

* * Example JSP Usage *
@@ -472,15 +479,13 @@ public static void forHtmlUnquotedAttribute(Writer out, String input)
      * Encoding  Notes
      * 
* Encoding Notes *