@GwtCompatible public final class UrlEscapers extends Object
Escaper
instances suitable for strings to be included in particular sections of URLs.
If the resulting URLs are inserted into an HTML or XML document, they will require additional
escaping with HtmlEscapers
or
XmlEscapers
.
Modifier and Type | Method and Description |
---|---|
static Escaper |
urlFormParameterEscaper()
Returns an
Escaper instance that escapes strings so they can be safely included in
URL form parameter names and values. |
static Escaper |
urlFragmentEscaper()
Returns an
Escaper instance that escapes strings so they can be safely included in a
URL fragment. |
static Escaper |
urlPathSegmentEscaper()
Returns an
Escaper instance that escapes strings so they can be safely included in
URL path segments. |
public static Escaper urlFormParameterEscaper()
Escaper
instance that escapes strings so they can be safely included in
URL form parameter names and values. Escaping is performed
with the UTF-8 character encoding. The caller is responsible for
replacing any unpaired carriage return or line feed characters
with a CR+LF pair on any non-file inputs before escaping them with this escaper.
When escaping a String, the following rules apply:
This escaper is suitable for escaping parameter names and values even when using the non-standard semicolon, rather than the ampersand, as a parameter delimiter. Nevertheless, we recommend using the ampersand unless you must interoperate with systems that require semicolons.
Note: Unlike other escapers, URL escapers produce uppercase hexadecimal sequences.
public static Escaper urlPathSegmentEscaper()
Escaper
instance that escapes strings so they can be safely included in
URL path segments. The returned escaper escapes all
non-ASCII characters, even though many of these are accepted in
modern URLs. (If the escaper were to leave these characters
unescaped, they would be escaped by the consumer at parse time, anyway.) Additionally, the
escaper escapes the slash character ("/"). While slashes are acceptable in URL paths, they are
considered by the specification to be separators between "path segments." This implies that, if
you wish for your path to contain slashes, you must escape each segment separately and then
join them.
When escaping a String, the following rules apply:
Note: Unlike other escapers, URL escapers produce uppercase hexadecimal sequences.
public static Escaper urlFragmentEscaper()
Escaper
instance that escapes strings so they can be safely included in a
URL fragment. The returned escaper escapes all non-ASCII
characters, even though many of these are accepted in modern
URLs.
When escaping a String, the following rules apply:
Note: Unlike other escapers, URL escapers produce uppercase hexadecimal sequences.
Copyright © 2010-2016. All Rights Reserved.