Package org.opencms.util
Class CmsParameterEscaper
java.lang.Object
org.opencms.util.CmsParameterEscaper
This class is responsible for automatically escaping parameters in Flex requests. It keeps track
of which parameters to escape (or not escape), and which parameters need to be processed by AntiSamy.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The file name of the default policy.protected static org.owasp.validator.html.Policy
The default policy, which is used when no policy path is given. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.owasp.validator.html.AntiSamy
createAntiSamy
(CmsObject cms, String policyPath) Creates a new AntiSamy instance for a given policy path.void
enableAntiSamy
(CmsObject cms, String policyPath, Set<String> params) Enables the AntiSamy HTML cleaning for some parameters.Escapes a single parameter value.String[]
Escapes an array of parameter values.protected String
escapeSimple
(String name, String value) Default escape function that doesn't do HTML filtering.filterAntiSamy
(String name, String html) Filters HTML input using the internal AntiSamy instance.static org.owasp.validator.html.Policy
readPolicy
(CmsObject cms, String sitePath) Helper method for reading an AntiSamy policy file from the VFS.void
setDummyValue
(String dummyValue) Sets the dummy value.void
setEscapeInvalid
(Collection<String> escapeInvalidList) Sets the parameters which should be escaped even if the dummy value is set.void
setExceptions
(Collection<String> exceptions) Sets the set of names of parameters which shouldn't be escaped.
-
Field Details
-
DEFAULT_POLICY
The file name of the default policy.- See Also:
-
defaultPolicy
The default policy, which is used when no policy path is given.
-
-
Constructor Details
-
CmsParameterEscaper
public CmsParameterEscaper()
-
-
Method Details
-
readPolicy
Helper method for reading an AntiSamy policy file from the VFS.- Parameters:
cms
- the current CMS contextsitePath
- the site path of the policy file- Returns:
- the policy object for the given path
-
createAntiSamy
Creates a new AntiSamy instance for a given policy path.- Parameters:
cms
- the current CMS contextpolicyPath
- the policy site path- Returns:
- the new AntiSamy instance
-
enableAntiSamy
Enables the AntiSamy HTML cleaning for some parameters.- Parameters:
cms
- the current CMS contextpolicyPath
- the policy site path in the VFSparams
- the parameters for which HTML cleaning should be enabled
-
escape
Escapes a single parameter value.- Parameters:
name
- the name of the parametervalue
- the value of the parameter- Returns:
- the escaped parameter value
-
escape
Escapes an array of parameter values.- Parameters:
name
- the parameter namevalues
- the parameter values- Returns:
- the escaped parameter values
-
filterAntiSamy
Filters HTML input using the internal AntiSamy instance.- Parameters:
name
- the parameter namehtml
- the HTML to filter- Returns:
- the filtered HTML
-
setDummyValue
Sets the dummy value.If the dummy value is set, then values which would otherwise be XML-escaped will be replaced with the dummy value instead.
- Parameters:
dummyValue
- the new value
-
setEscapeInvalid
Sets the parameters which should be escaped even if the dummy value is set.- Parameters:
escapeInvalidList
- the collection of parameters which should be escaped even if the dummy value is set
-
setExceptions
Sets the set of names of parameters which shouldn't be escaped.- Parameters:
exceptions
- a set of parameter names
-
escapeSimple
Default escape function that doesn't do HTML filtering.- Parameters:
name
- the parameter namevalue
- the parameter value- Returns:
- the escaped value
-