public final class HtmlUtil extends Object
Modifier and Type | Field and Description |
---|---|
static com.google.common.base.Function<String,String> |
HTML_ENCODE_FUNCTION
Function to apply
htmlEncode(String) . |
Constructor and Description |
---|
HtmlUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
completeUrlEncode(String url)
Encodes the given url for protocols which the
CompleteURLEncoder supports. |
static String |
htmlEncode(String text)
Encodes the given text to be HTML safe using entity escapes.
|
static String |
htmlEncodeAndReplaceSpaces(String text)
Encodes the given text to be HTML safe using entity escapes, and embedding non-breaking spaces in place of spaces.
|
static String |
reencodeURL(String originalUrl)
Attempts to handle common encoding errors in hand-edited URLs, such as failing to URL encode quotes.
|
static boolean |
shouldUrlDecode(String text)
Checks if the given text should contains any percent encoded characters that should be decoded.
|
static String |
urlDecode(String url)
Decodes URL percent encoded characters, using the character encoding as per
GeneralUtil.getCharacterEncoding() . |
static String |
urlDecode(String url,
String encoding)
Decodes URL percent encoded characters.
|
static String |
urlEncode(String text)
Encodes HTTP form parameter/values, using the character encoding as per
GeneralUtil.getCharacterEncoding() . |
static String |
urlEncode(String text,
String encoding)
Encodes HTTP form parameter/values.
|
public static final com.google.common.base.Function<String,String> HTML_ENCODE_FUNCTION
htmlEncode(String)
.public static String htmlEncode(String text)
text
- the text to encode.public static String htmlEncodeAndReplaceSpaces(String text)
text
- the text to encode.public static String completeUrlEncode(String url)
CompleteURLEncoder
supports. To only encode HTTP form parameter/values
or fragments, use urlEncode(String)
instead. Uses the character encoding as per GeneralUtil.getCharacterEncoding()
.url
- the entire URL to encodepublic static String urlEncode(String text)
GeneralUtil.getCharacterEncoding()
.
To encode entire URLs, use completeUrlEncode(java.lang.String)
instead.text
- part of the url to encodepublic static String urlEncode(String text, String encoding)
completeUrlEncode(java.lang.String)
instead.text
- part of the url to encodeencoding
- the character encoding to usepublic static String urlDecode(String url)
GeneralUtil.getCharacterEncoding()
.url
- the URL to decodepublic static String urlDecode(String url, String encoding) throws UnsupportedEncodingException
url
- the URL to decodeencoding
- the character encoding to use while decodingUnsupportedEncodingException
public static boolean shouldUrlDecode(String text)
text
- the text to checkCopyright © 2003–2019 Atlassian. All rights reserved.