public class Filter extends Object
Constructor and Description |
---|
Filter() |
Modifier and Type | Method and Description |
---|---|
static String |
asCssColor(String color)
asCssColor is useful when you need to insert dynamic data into a CSS color context, e.g.
|
static String |
asCssColor(String color,
String defaultColor)
Identical to asCssColor, except you can provide your own default value
|
static String |
asFlexibleURL(String url)
This function should be semantically identical to the above function with the exception
of using a scheme blacklist instead of a scheme whitelist.
|
static String |
asNumber(String number)
asNumber is useful for outputting dynamic data as a number in a JavaScript
context, e.g.
|
static String |
asNumber(String number,
String defaultNumber)
Identical to asNumber, except you can provide your own default value
|
static String |
asURL(String url)
URL filtering to ensure that the URL is a safe non-relative URL or transforms it to a safe relative URL.
|
public static String asNumber(String number)
number
- the potential number to filterpublic static String asNumber(String number, String defaultNumber)
number
- the potential number to filterdefaultNumber
- a default String to return if the number argument is not a Numberpublic static String asCssColor(String color)
color
- the potential css color to filterpublic static String asCssColor(String color, String defaultColor)
color
- the potential css color to filterdefaultColor
- a default String to return if the color argument is not a potentially valid CSS colorpublic static String asURL(String url)
url
- The potentially tainted URL to be Filterednull
if input
is nullpublic static String asFlexibleURL(String url)
javascript
, vbscript
, data
and about
URL schemes and turns these URLs into relative URLs the same way the above does.
It allows all other schemes as long as the scheme name is directly followed by a colon (:)
The complexity of this function is necessary due to the parsing that browsers do when
they encounter URLs, e.g. stripping new lines and NUL bytes.url
- The potentially tainted URL to be Filterednull
if input
is nullCopyright © 2016. All Rights Reserved.