Skip to content

Commit 5096211

Browse files
Added the new escaper to the CharEscapers utility class
1 parent 9cb79d1 commit 5096211

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public final class CharEscapers {
4444
private static final Escaper URI_QUERY_STRING_ESCAPER =
4545
new PercentEscaper(PercentEscaper.SAFEQUERYSTRINGCHARS_URLENCODER);
4646

47+
private static final Escaper URI_RESERVED_AND_PERCENT_ENCODED_ESCAPER =
48+
new PercentEncodedEscaper(URI_RESERVED_ESCAPER);
49+
4750
/**
4851
* Escapes the string value so it can be safely included in application/x-www-form-urlencoded
4952
* data. This is not appropriate for generic URI escaping. In particular it encodes the space
@@ -184,6 +187,14 @@ public static String escapeUriPathWithoutReserved(String value) {
184187
return URI_RESERVED_ESCAPER.escape(value);
185188
}
186189

190+
/**
191+
* Escapes a URI path but retains all reserved and percent-encoded characters. That is the same as
192+
* {@link #escapeUriPathWithoutReserved(String)} except that it also escapes percent encoded parts.
193+
*/
194+
public static String escapeUriPathWithoutReservedAndPercentEncoded(String value) {
195+
return URI_RESERVED_AND_PERCENT_ENCODED_ESCAPER.escape(value);
196+
}
197+
187198
/**
188199
* Escapes the string value so it can be safely included in URI user info part. For details on
189200
* escaping URIs, see <a href="http://tools.ietf.org/html/rfc3986#section-2.4">RFC 3986 - section

0 commit comments

Comments
 (0)