Package com.adobe.granite.xss
Interface XSSAPI
Deprecated.
A service providing validators and encoders for XSS protection during the composition of HTML pages.
Note: in general, validators are safer than encoders. Encoding only ensures that content within the encoded context cannot break out of said context. It requires that there be a context (for instance, a string context in Javascript), and that damage cannot be done from within the context (for instance, a javascript: URL within a href attribute.
When in doubt, use a validator.
-
Method Summary
Modifier and TypeMethodDescriptionencodeForHTML(String source) Deprecated.Encodes a source string for HTML element content.encodeForHTMLAttr(String source) Deprecated.Encodes a source string for writing to an HTML attribute value.encodeForJSString(String source) Deprecated.Encodes a source string for writing to JavaScript string content.encodeForXML(String source) Deprecated.Encodes a source string for XML element content.encodeForXMLAttr(String source) Deprecated.Encodes a source string for writing to an XML attribute value.filterHTML(String source) Deprecated.Filters potentially user-contributed HTML to meet the AntiSamy policy rules currently in effect for HTML output (see the XSSFilter service for details).Deprecated.Returns an XSSAPI instance capable of mapping resource URLs.getResourceResolverSpecificAPI(ResourceResolver resourceResolver) Deprecated.Returns an XSSAPI instance capable of mapping resource URLs.getValidCSSColor(String color, String defaultColor) Deprecated.Validate a CSS color value.getValidDimension(String dimension, String defaultValue) Deprecated.Validate a string which should contain a dimension, returning a default value if the source is empyt, can't be parsed, or contains XSS risks.getValidHref(String url) Deprecated.Sanitizes a URL for writing as an HTML href or src attribute value.getValidHref(String url, boolean isPath) Deprecated.getValidInteger(String integer, int defaultValue) Deprecated.Validate a string which should contain an integer, returning a default value if the source is empty, can't be parsed, or contains XSS risks.getValidJSToken(String token, String defaultValue) Deprecated.Validate a Javascript token.getValidLong(String source, long defaultValue) Deprecated.Validate a string which should contain a long, returning a default value if the source is empty, can't be parsed, or contains XSS risks.
-
Method Details
-
getValidInteger
Deprecated.Validate a string which should contain an integer, returning a default value if the source is empty, can't be parsed, or contains XSS risks.- Parameters:
integer- the source integerdefaultValue- a default value if the source can't be used- Returns:
- a sanitized integer
-
getValidLong
Deprecated.Validate a string which should contain a long, returning a default value if the source is empty, can't be parsed, or contains XSS risks.- Parameters:
source- the source longdefaultValue- a default value if the source can't be used- Returns:
- a sanitized integer
-
getValidDimension
Deprecated.Validate a string which should contain a dimension, returning a default value if the source is empyt, can't be parsed, or contains XSS risks. Allows integer dimensions and the keyword "auto".- Parameters:
dimension- the source dimensiondefaultValue- a default value if the source can't be used- Returns:
- a sanitized dimension
-
getValidHref
Deprecated.Sanitizes a URL for writing as an HTML href or src attribute value.- Parameters:
url- the source URL- Returns:
- a sanitized URL (possibly empty)
-
getValidHref
Deprecated. -
getValidJSToken
Deprecated.Validate a Javascript token. The value must be either a single identifier, a literal number, or a literal string.- Parameters:
token- the source tokendefaultValue- a default value to use if the source doesn't meet validity constraints.- Returns:
- a string containing a single identifier, a literal number, or a literal string token
-
getValidCSSColor
Deprecated.Validate a CSS color value. Color values as specified at http://www.w3.org/TR/css3-color/#colorunits are safe and definitively allowed. Vulnerable constructs will be disallowed. Currently known vulnerable constructs include url(...), expression(...), and anything with a semicolon.- Parameters:
color- the color value to be used.defaultColor- a default value to use if the input color value doesn't meet validity constraints.- Returns:
- a string a css color value.
-
encodeForHTML
Deprecated.Encodes a source string for HTML element content. DO NOT USE FOR WRITING ATTRIBUTE VALUES!- Parameters:
source- the source string to encode- Returns:
- an encoded version of the source
-
encodeForHTMLAttr
Deprecated.Encodes a source string for writing to an HTML attribute value. DO NOT USE FOR ACTIONABLE ATTRIBUTES (href, src, event handlers); YOU MUST USE A VALIDATOR FOR THOSE!- Parameters:
source- the source string to encode- Returns:
- an encoded version of the source
-
encodeForXML
Deprecated.Encodes a source string for XML element content. DO NOT USE FOR WRITING ATTRIBUTE VALUES!- Parameters:
source- the source string to encode- Returns:
- an encoded version of the source
-
encodeForXMLAttr
Deprecated.Encodes a source string for writing to an XML attribute value.- Parameters:
source- the source string to encode- Returns:
- an encoded version of the source
-
encodeForJSString
Deprecated.Encodes a source string for writing to JavaScript string content. DO NOT USE FOR WRITING TO ARBITRARY JAVASCRIPT; YOU MUST USE A VALIDATOR FOR THAT. (Encoding only ensures that the source material cannot break out of its context.)- Parameters:
source- the source string to encode- Returns:
- an encoded version of the source
-
filterHTML
Deprecated.Filters potentially user-contributed HTML to meet the AntiSamy policy rules currently in effect for HTML output (see the XSSFilter service for details).- Parameters:
source- a string containing the source HTML- Returns:
- a string containing the sanitized HTML
-
getRequestSpecificAPI
Deprecated.Returns an XSSAPI instance capable of mapping resource URLs. EITHER THIS OR THE RESOURCERESOLVER VERSION MUST BE USED WHEN VALIDATING HREFs!- Parameters:
request- the request- Returns:
- an XSSAPI service capable of validating hrefs.
-
getResourceResolverSpecificAPI
Deprecated.Returns an XSSAPI instance capable of mapping resource URLs. EITHER THIS OR THE REQUEST VERSION MUST BE USED WHEN VALIDATING HREFs!- Parameters:
resourceResolver- the resource resolver- Returns:
- an XSSAPI service capable of validating hrefs.
-
XSSAPIinstead.