SecureFilter contains many methods for manipulating untrusted data Strings
into RFC-Compliant Strings for a given context by removing “bad” data from
the untrusted data.
Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Filters illegal characters from a given input for use in a general HTML
context. E.g. text content and text attributes. This method takes the
UNION of allowed characters among all contexts, so may be more
imprecise that the more specific contexts. Generally, this method is
preferred unless you specifically understand the context in which
untrusted data will be output.
Filters illegal characters from a given input for use in an HTML
Attribute guarded by a double quote. This method is preferred if you
understand exactly how the output of this will be used in the HTML
document.
Filters illegal characters from a given input for use in an HTML
Attribute guarded by a single quote. This method is preferred if you
understand exactly how the output of this will be used in the HTML
document.
Filters illegal characters from a given input for use in an HTML
Attribute left unguarded. This method is preferred if you understand
exactly how the output of this will be used in the HTML document.
Filters illegal characters from a given input for use in JavaScript
inside an HTML attribute. This method is preferred if you understand
exactly how the output of the will be used in the page
Filters illegal characters from a given input for use in JavaScript
inside an HTML block. This method is preferred if you understand
exactly how the output of the will be used in the page
Example Usage:
1<script type="text/javascript">2 var data = "${SecureFilter.forJavaScriptInBlock(unsafeData)}";3</script>
Flow:
Allow AlphaNumerics and some Special characters
Remove all other characters
Parameters:
input - untrusted input to be filtered, if necessary
Filters illegal characters from a given input for use in JavaScript
inside an HTML context. This method takes the UNION of allowed
characters among the other contexts, so may be more imprecise that the
more specific contexts. Generally, this method is preferred unless you
specifically understand the context in which untrusted data will be
output.
Example Usage:
1<script type="text/javascript">2 var data = "${SecureFilter.forJavaScriptInHTML(unsafeData)}";3</script>45<button onclick="alert('${SecureFilter.forJavaScriptInHTML(unsafeData)}');">
Flow:
Allow AlphaNumerics and some Special characters
Remove all other characters
Parameters:
input - untrusted input to be filtered, if necessary
Filters illegal characters from a given input for use in JavaScript
inside a JavaScript source file. This method is preferred if you
understand exactly how the output of the will be used in the page
Example Usage:
1<...inside foobar.js...>2var data = "${SecureFilter.forJavaScriptInSource(unsafeData)}";
Flow:
Allow AlphaNumerics and some Special characters
Remove all other characters
Parameters:
input - untrusted input to be filtered, if necessary
Filters illegal characters from a given input for use as a component
of a URI. This is equivalent to javascript's filterURIComponent and
does a realistic job of encoding.
Filters illegal characters from a given input for use in an XML
comments. This method is preferred if you understand the context in
which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method
can be misused, but is left here if a parser is unavailable to you
Filters illegal characters from a given input for use in a general XML
context. E.g. text content and text attributes. This method takes the
UNION of allowed characters between the other contexts, so may be more
imprecise that the more specific contexts. Generally, this method is
preferred unless you specifically understand the context in which
untrusted data will be output.
Note: It is recommended that you use a real parser, as this method
can be misused, but is left here if a parser is unavailable to you
Filters illegal characters from a given input for use in an XML
attribute guarded by a double quote. This method is preferred if you
understand the context in which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method
can be misused, but is left here if a parser is unavailable to you
Filters illegal characters from a given input for use in an XML
attribute guarded by a single quote. This method is preferred if you
understand the context in which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method
can be misused, but is left here if a parser is unavailable to you