public enum SanitizedContentKind extends Enum<SanitizedContentKind>
kind=\"...\" parameter to soy templates and content
blocks.
This is the enum that should be used internally by the compiler. The analagous public
interface is SanitizedContent.ContentKind which should be used by the Java backends to
communicate kind information with callers.
| Enum Constant and Description |
|---|
ATTRIBUTES
An attribute name and value, such as
dir="ltr". |
CSS
A CSS3 declaration, property, value or group of semicolon separated declarations.
|
HTML
A snippet of HTML that does not start or end inside a tag, comment, entity, or DOCTYPE; and
that does not contain any executable code (JS,
<object>s, etc.) from a different trust
domain. |
JS
Executable Javascript code or expression, safe for insertion in a script-tag or event handler
context, known to be free of any attacker-controlled scripts.
|
TEXT
Unsanitized plain-text content.
|
TRUSTED_RESOURCE_URI
Resource URIs used in script sources, stylesheets, etc which are not in attacker control.
|
URI
A properly encoded portion of a URI.
|
| Modifier and Type | Method and Description |
|---|---|
String |
asAttributeValue()
Returns the kind formatted as it would be for an attribute value.
|
static com.google.common.collect.ImmutableSet<String> |
attributeValues()
Returns all the valid attribute values.
|
static com.google.common.base.Optional<SanitizedContentKind> |
fromAttributeValue(String attributeValue)
Returns the kind for the given attribute value.
|
static SanitizedContentKind |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static SanitizedContentKind[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final SanitizedContentKind HTML
<object>s, etc.) from a different trust
domain.public static final SanitizedContentKind JS
public static final SanitizedContentKind URI
public static final SanitizedContentKind TRUSTED_RESOURCE_URI
public static final SanitizedContentKind ATTRIBUTES
dir="ltr".public static final SanitizedContentKind CSS
public static final SanitizedContentKind TEXT
This is effectively the "null" entry of this enum, and is sometimes used to explicitly mark content that should never be used unescaped. Since any string is safe to use as text, being of ContentKind.TEXT makes no guarantees about its safety in any other context such as HTML.
In the soy type system, TEXT is equivalent to the string type.
public static SanitizedContentKind[] values()
for (SanitizedContentKind c : SanitizedContentKind.values()) System.out.println(c);
public static SanitizedContentKind valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic String asAttributeValue()
public static com.google.common.base.Optional<SanitizedContentKind> fromAttributeValue(String attributeValue)
null if it is invalid.public static com.google.common.collect.ImmutableSet<String> attributeValues()