Package org.owasp.encoder
Enum JavaScriptEncoder.Mode
- java.lang.Object
-
- java.lang.Enum<JavaScriptEncoder.Mode>
-
- org.owasp.encoder.JavaScriptEncoder.Mode
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<JavaScriptEncoder.Mode>
- Enclosing class:
- JavaScriptEncoder
static enum JavaScriptEncoder.Mode extends java.lang.Enum<JavaScriptEncoder.Mode>
Mode of operation constants for the JavaScriptEncoder.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
Mode()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static JavaScriptEncoder.Mode
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static JavaScriptEncoder.Mode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
SOURCE
public static final JavaScriptEncoder.Mode SOURCE
Standard encoding of JavaScript Strings. Escape sequences are chosen according to what is the shortest sequence possible for the character.
-
ATTRIBUTE
public static final JavaScriptEncoder.Mode ATTRIBUTE
Encoding for use in HTML attributes. Quote characters are escaped using hex encodes instead of backslashes. The alternate would be to use a sequence of encodes that would actually be longer. In this mode double-quote is "\x22" and single-quote is "\x27". (In HTML attributes the alternate would be encoding "\"" and "\'" with entity escapes to "\"" and "\&39;").
-
BLOCK
public static final JavaScriptEncoder.Mode BLOCK
Encoding for use in HTML script blocks. The main concern here is permaturely terminating a script block with a closing "</" inside the string. This encoding escapes "/" as "\/" to prevent such termination.
-
HTML
public static final JavaScriptEncoder.Mode HTML
Encodes for use in either HTML script attributes or blocks. Essentially this is both special escapes from HTML_ATTRIBUTE and HTML_CONTENT combined.
-
-
Method Detail
-
values
public static JavaScriptEncoder.Mode[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JavaScriptEncoder.Mode c : JavaScriptEncoder.Mode.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JavaScriptEncoder.Mode valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-