Package org.owasp.html
Class Encoding
- java.lang.Object
-
- org.owasp.html.Encoding
-
public final class Encoding extends Object
Encoders and decoders for HTML.
-
-
Constructor Summary
Constructors Constructor Description Encoding()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
decodeHtml(String s)
Deprecated.specify whether s is in an attribute valuestatic String
decodeHtml(String s, boolean inAttribute)
Decodes HTML entities to produce a string containing only valid Unicode scalar values.static void
encodeRcdataOnto(String plainText, Appendable output)
Appends an encoded form of plainText to putput where the encoding is sufficient to prevent an HTML parser from transitioning out of the RCDATA state.
-
-
-
Method Detail
-
decodeHtml
public static String decodeHtml(String s)
Deprecated.specify whether s is in an attribute valueDecodes HTML entities to produce a string containing only valid Unicode scalar values.- Parameters:
s
- text/html- Returns:
- text/plain
-
decodeHtml
public static String decodeHtml(String s, boolean inAttribute)
Decodes HTML entities to produce a string containing only valid Unicode scalar values.- Parameters:
s
- text/htmlinAttribute
- is s in an attribute value?- Returns:
- text/plain
-
encodeRcdataOnto
public static void encodeRcdataOnto(String plainText, Appendable output) throws IOException
Appends an encoded form of plainText to putput where the encoding is sufficient to prevent an HTML parser from transitioning out of the RCDATA state. This is suitable for encoding a text node inside a<textarea>
or<title>
element outside foreign content.- Parameters:
plainText
- text/plainoutput
- a buffer of text/html that has a well-formed HTML prefix that would leave an HTML parser in the Data state if it were to encounter a space character as the next character. In practice this means that the buffer does not contain partial tags or comments, and the most recently opened element is `- Throws:
IOException
-
-