diff --git a/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java b/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java
index 62bc14ec7..8028d63c6 100644
--- a/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java
+++ b/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java
@@ -29,7 +29,7 @@
/**
* Low-level JSON library implementation based on Jackson 2.
*
- * Implementation is thread-safe, and sub-classes must be thread-safe. For maximum efficiency,
+ *
Implementation is thread-safe. For maximum efficiency,
* applications should use a single globally-shared instance of the JSON factory.
*
* @since 1.11
diff --git a/google-http-client-protobuf/pom.xml b/google-http-client-protobuf/pom.xml
index a5079f435..11cfa76fc 100644
--- a/google-http-client-protobuf/pom.xml
+++ b/google-http-client-protobuf/pom.xml
@@ -4,11 +4,11 @@
com.google.http-client
google-http-client-parent
- 1.34.1
+ 1.34.2
../pom.xml
google-http-client-protobuf
- 1.34.1
+ 1.34.2
Protocol Buffer extensions to the Google HTTP Client Library for Java.
diff --git a/google-http-client-test/pom.xml b/google-http-client-test/pom.xml
index 4a756e0c7..d2c9dc1c8 100644
--- a/google-http-client-test/pom.xml
+++ b/google-http-client-test/pom.xml
@@ -4,11 +4,11 @@
com.google.http-client
google-http-client-parent
- 1.34.1
+ 1.34.2
../pom.xml
google-http-client-test
- 1.34.1
+ 1.34.2
Shared classes used for testing of artifacts in the Google HTTP Client Library for Java.
diff --git a/google-http-client-xml/pom.xml b/google-http-client-xml/pom.xml
index 462f8a61b..ac1cb4a7b 100644
--- a/google-http-client-xml/pom.xml
+++ b/google-http-client-xml/pom.xml
@@ -4,11 +4,11 @@
com.google.http-client
google-http-client-parent
- 1.34.1
+ 1.34.2
../pom.xml
google-http-client-xml
- 1.34.1
+ 1.34.2
XML extensions to the Google HTTP Client Library for Java.
diff --git a/google-http-client-xml/src/main/java/com/google/api/client/xml/atom/Atom.java b/google-http-client-xml/src/main/java/com/google/api/client/xml/atom/Atom.java
index 85b39b0a9..c948bd36d 100644
--- a/google-http-client-xml/src/main/java/com/google/api/client/xml/atom/Atom.java
+++ b/google-http-client-xml/src/main/java/com/google/api/client/xml/atom/Atom.java
@@ -49,7 +49,7 @@ public final class Atom {
/** Escaper for the {@code Slug} header. */
private static final PercentEscaper SLUG_ESCAPER =
- new PercentEscaper(" !\"#$&'()*+,-./:;<=>?@[\\]^_`{|}~", false);
+ new PercentEscaper(" !\"#$&'()*+,-./:;<=>?@[\\]^_`{|}~");
static final class StopAtAtomEntry extends Xml.CustomizeParser {
diff --git a/google-http-client/pom.xml b/google-http-client/pom.xml
index c79a16661..1b033d480 100644
--- a/google-http-client/pom.xml
+++ b/google-http-client/pom.xml
@@ -4,11 +4,11 @@
com.google.http-client
google-http-client-parent
- 1.34.1
+ 1.34.2
../pom.xml
google-http-client
- 1.34.1
+ 1.34.2
Google HTTP Client Library for Java
Google HTTP Client Library for Java. Functionality that works on all supported Java platforms,
diff --git a/google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java b/google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java
index 45e9d5ab5..3204f695e 100644
--- a/google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java
+++ b/google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java
@@ -52,8 +52,7 @@
*/
public class GenericUrl extends GenericData {
- private static final Escaper URI_FRAGMENT_ESCAPER =
- new PercentEscaper("=&-_.!~*'()@:$,;/?:", false);
+ private static final Escaper URI_FRAGMENT_ESCAPER = new PercentEscaper("=&-_.!~*'()@:$,;/?:");
/** Scheme (lowercase), for example {@code "https"}. */
private String scheme;
@@ -90,7 +89,7 @@ public class GenericUrl extends GenericData {
public GenericUrl() {}
/**
- * Constructs from an encoded URL.
+ * Constructs a GenericUrl from a URL encoded string.
*
* Any known query parameters with pre-defined fields as data keys will be parsed based on
* their data type. Any unrecognized query parameter will always be parsed as a string.
@@ -103,17 +102,17 @@ public GenericUrl() {}
* compliant with, at least, RFC 3986.
*
* @param encodedUrl encoded URL, including any existing query parameters that should be parsed
- * @throws IllegalArgumentException if URL has a syntax error
+ * @throws IllegalArgumentException if the URL has a syntax error
*/
public GenericUrl(String encodedUrl) {
this(encodedUrl, false);
}
/**
- * Constructs from an encoded URL.
+ * Constructs a GenericUrl from a string.
*
- *
Any known query parameters with pre-defined fields as data keys are parsed based on their
- * data type. Any unrecognized query parameter are always parsed as a string.
+ *
Any known query parameters with pre-defined fields as data keys will be parsed based on
+ * their data type. Any unrecognized query parameter will always be parsed as a string.
*
*
Any {@link MalformedURLException} is wrapped in an {@link IllegalArgumentException}.
*
@@ -216,7 +215,6 @@ private GenericUrl(
@Override
public int hashCode() {
- // TODO(yanivi): optimize?
return build().hashCode();
}
@@ -229,7 +227,6 @@ public boolean equals(Object obj) {
return false;
}
GenericUrl other = (GenericUrl) obj;
- // TODO(yanivi): optimize?
return build().equals(other.build());
}
diff --git a/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java b/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java
index fcf25fa49..61071db68 100644
--- a/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java
+++ b/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java
@@ -55,7 +55,7 @@
*/
public class UriTemplate {
- static final Map COMPOSITE_PREFIXES =
+ private static final Map COMPOSITE_PREFIXES =
new HashMap();
static {
@@ -98,14 +98,14 @@ private enum CompositeOutput {
private final boolean reservedExpansion;
/**
- * @param propertyPrefix The prefix of a parameter or {@code null} for none. In {+var} the
+ * @param propertyPrefix the prefix of a parameter or {@code null} for none. In {+var} the
* prefix is '+'
- * @param outputPrefix The string that should be prefixed to the expanded template.
- * @param explodeJoiner The delimiter used to join composite values.
- * @param requiresVarAssignment Denotes whether or not the expanded template should contain an
- * assignment with the variable.
- * @param reservedExpansion Reserved expansion allows pct-encoded triplets and characters in the
- * reserved set.
+ * @param outputPrefix the string that should be prefixed to the expanded template.
+ * @param explodeJoiner the delimiter used to join composite values.
+ * @param requiresVarAssignment denotes whether or not the expanded template should contain an
+ * assignment with the variable
+ * @param reservedExpansion reserved expansion allows percent-encoded triplets and characters in the
+ * reserved set
*/
CompositeOutput(
Character propertyPrefix,
@@ -149,26 +149,22 @@ int getVarNameStartIndex() {
}
/**
- * Encodes the specified value. If reserved expansion is turned on then pct-encoded triplets and
+ * Encodes the specified value. If reserved expansion is turned on, then percent-encoded triplets and
* characters are allowed in the reserved set.
*
- * @param value The string to be encoded.
- * @return The encoded string.
+ * @param value the string to be encoded
+ * @return the encoded string
*/
- String getEncodedValue(String value) {
+ private String getEncodedValue(String value) {
String encodedValue;
if (reservedExpansion) {
- // Reserved expansion allows pct-encoded triplets and characters in the reserved set.
+ // Reserved expansion allows percent-encoded triplets and characters in the reserved set.
encodedValue = CharEscapers.escapeUriPathWithoutReserved(value);
} else {
- encodedValue = CharEscapers.escapeUri(value);
+ encodedValue = CharEscapers.escapeUriConformant(value);
}
return encodedValue;
}
-
- boolean getReservedExpansion() {
- return reservedExpansion;
- }
}
static CompositeOutput getCompositeOutput(String propertyName) {
@@ -334,12 +330,12 @@ private static String getSimpleValue(String name, String value, CompositeOutput
* Expand the template of a composite list property. Eg: If d := ["red", "green", "blue"] then
* {/d*} is expanded to "/red/green/blue"
*
- * @param varName The name of the variable the value corresponds to. Eg: "d"
- * @param iterator The iterator over list values. Eg: ["red", "green", "blue"]
- * @param containsExplodeModifier Set to true if the template contains the explode modifier "*"
- * @param compositeOutput An instance of CompositeOutput. Contains information on how the
+ * @param varName the name of the variable the value corresponds to. E.g. "d"
+ * @param iterator the iterator over list values. E.g. ["red", "green", "blue"]
+ * @param containsExplodeModifiersSet to true if the template contains the explode modifier "*"
+ * @param compositeOutput an instance of CompositeOutput. Contains information on how the
* expansion should be done
- * @return The expanded list template
+ * @return the expanded list template
* @throws IllegalArgumentException if the required list path parameter is empty
*/
private static String getListPropertyValue(
@@ -378,12 +374,11 @@ private static String getListPropertyValue(
* Expand the template of a composite map property. Eg: If d := [("semi", ";"),("dot",
* "."),("comma", ",")] then {/d*} is expanded to "/semi=%3B/dot=./comma=%2C"
*
- * @param varName The name of the variable the value corresponds to. Eg: "d"
- * @param map The map property value. Eg: [("semi", ";"),("dot", "."),("comma", ",")]
+ * @param varName the name of the variable the value corresponds to. Eg: "d"
+ * @param map the map property value. Eg: [("semi", ";"),("dot", "."),("comma", ",")]
* @param containsExplodeModifier Set to true if the template contains the explode modifier "*"
- * @param compositeOutput An instance of CompositeOutput. Contains information on how the
- * expansion should be done
- * @return The expanded map template
+ * @param compositeOutput contains information on how the expansion should be done
+ * @return the expanded map template
* @throws IllegalArgumentException if the required list path parameter is map
*/
private static String getMapPropertyValue(
diff --git a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java
index fb5ec5375..14c3238f7 100644
--- a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java
+++ b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java
@@ -83,7 +83,7 @@ public class UrlEncodedParser implements ObjectParser {
public static void parse(String content, Object data) {
parse(content, data, true);
}
-
+
/**
* Parses the given URL-encoded content into the given data object of data key name/value pairs
* using {@link #parse(Reader, Object)}.
@@ -92,7 +92,7 @@ public static void parse(String content, Object data) {
* @param data data key name/value pairs
* @param decodeEnabled flag that specifies whether decoding should be enabled.
*/
- public static void parse(String content, Object data, boolean decodeEnabled) {
+ public static void parse(String content, Object data, boolean decodeEnabled) {
if (content == null) {
return;
}
@@ -103,6 +103,7 @@ public static void parse(String content, Object data, boolean decodeEnabled) {
throw Throwables.propagate(exception);
}
}
+
/**
* Parses the given URL-encoded content into the given data object of data key name/value pairs,
* including support for repeating data key names.
diff --git a/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java b/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java
index 062e082d8..9d61f8af0 100644
--- a/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java
+++ b/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010 Google Inc.
+
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -19,31 +20,38 @@
import java.nio.charset.StandardCharsets;
/**
- * Utility functions for dealing with {@code CharEscaper}s, and some commonly used {@code
- * CharEscaper} instances.
+ * Utility functions for encoding and decoding URIs.
*
* @since 1.0
*/
public final class CharEscapers {
- private static final Escaper URI_ESCAPER =
+ private static final Escaper APPLICATION_X_WWW_FORM_URLENCODED =
new PercentEscaper(PercentEscaper.SAFECHARS_URLENCODER, true);
+ private static final Escaper URI_ESCAPER =
+ new PercentEscaper(PercentEscaper.SAFECHARS_URLENCODER, false);
+
private static final Escaper URI_PATH_ESCAPER =
- new PercentEscaper(PercentEscaper.SAFEPATHCHARS_URLENCODER, false);
+ new PercentEscaper(PercentEscaper.SAFEPATHCHARS_URLENCODER);
private static final Escaper URI_RESERVED_ESCAPER =
- new PercentEscaper(PercentEscaper.SAFE_PLUS_RESERVED_CHARS_URLENCODER, false);
+ new PercentEscaper(PercentEscaper.SAFE_PLUS_RESERVED_CHARS_URLENCODER);
private static final Escaper URI_USERINFO_ESCAPER =
- new PercentEscaper(PercentEscaper.SAFEUSERINFOCHARS_URLENCODER, false);
+ new PercentEscaper(PercentEscaper.SAFEUSERINFOCHARS_URLENCODER);
private static final Escaper URI_QUERY_STRING_ESCAPER =
- new PercentEscaper(PercentEscaper.SAFEQUERYSTRINGCHARS_URLENCODER, false);
+ new PercentEscaper(PercentEscaper.SAFEQUERYSTRINGCHARS_URLENCODER);
/**
- * Escapes the string value so it can be safely included in URIs. For details on escaping URIs,
- * see RFC 3986 - section 2.4.
+ * Escapes the string value so it can be safely included in application/x-www-form-urlencoded
+ * data. This is not appropriate for generic URI escaping. In particular it encodes
+ * the space character as a plus sign instead of percent escaping it, in
+ * contravention of the URI specification.
+ * For details on application/x-www-form-urlencoded encoding see the
+ * see HTML 4
+ * specification, section 17.13.4.1.
*
* When encoding a String, the following rules apply:
*
@@ -68,19 +76,46 @@ public final class CharEscapers {
*
{@link java.net.URLEncoder#encode(String, String)} with the encoding name "UTF-8"
*
*/
+ @Deprecated
public static String escapeUri(String value) {
+ return APPLICATION_X_WWW_FORM_URLENCODED.escape(value);
+ }
+
+ /**
+ * Escapes the string value so it can be safely included in any part of a URI.
+ * For details on escaping URIs,
+ * see RFC 3986 - section 2.4.
+ *
+ * When encoding a String, the following rules apply:
+ *
+ *
+ * - The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain
+ * the same.
+ *
- The special characters ".", "-", "*", and "_" remain the same.
+ *
- The space character " " is converted into "%20".
+ *
- All other characters are converted into one or more bytes using UTF-8 encoding and each
+ * byte is then represented by the 3-character string "%XY", where "XY" is the two-digit,
+ * uppercase, hexadecimal representation of the byte value.
+ *
+ *
+ * Note: Unlike other escapers, URI escapers produce uppercase hexadecimal sequences.
+ * From RFC 3986:
+ * "URI producers and normalizers should use uppercase hexadecimal digits for all
+ * percent-encodings."
+ */
+ public static String escapeUriConformant(String value) {
return URI_ESCAPER.escape(value);
}
/**
- * Percent-decodes a US-ASCII string into a Unicode string. UTF-8 encoding is used to determine
+ * Decodes application/x-www-form-urlencoded strings. The UTF-8 character set determines
* what characters are represented by any consecutive sequences of the form "%XX".
*
- *
This replaces each occurrence of '+' with a space, ' '. So this method should not be used
- * for non application/x-www-form-urlencoded strings such as host and path.
+ *
This replaces each occurrence of '+' with a space, ' '. This method should not be used
+ * for non-application/x-www-form-urlencoded strings such as host and path.
*
* @param uri a percent-encoded US-ASCII string
- * @return a Unicode string
+ * @return a string without any percent escapes or plus signs
*/
public static String decodeUri(String uri) {
try {
@@ -92,11 +127,11 @@ public static String decodeUri(String uri) {
}
/**
- * Decodes the path component of a URI. This must be done via a method that does not try to
- * convert + into spaces(the behavior of {@link java.net.URLDecoder#decode(String, String)}). This
+ * Decodes the path component of a URI. This does not
+ * convert + into spaces (the behavior of {@link java.net.URLDecoder#decode(String, String)}). This
* method transforms URI encoded values into their decoded symbols.
*
- *
i.e: {@code decodePath("%3Co%3E")} would return {@code ""}
+ * e.g. {@code decodePath("%3Co%3E")} returns {@code ""}
*
* @param path the value to be decoded
* @return decoded version of {@code path}
@@ -144,7 +179,7 @@ public static String escapeUriPath(String value) {
/**
* Escapes a URI path but retains all reserved characters, including all general delimiters. That
- * is the same as {@link #escapeUriPath(String)} except that it keeps '?', '+', and '/' unescaped.
+ * is the same as {@link #escapeUriPath(String)} except that it does not escape '?', '+', and '/'.
*/
public static String escapeUriPathWithoutReserved(String value) {
return URI_RESERVED_ESCAPER.escape(value);
diff --git a/google-http-client/src/test/java/com/google/api/client/http/ConsumingInputStreamTest.java b/google-http-client/src/test/java/com/google/api/client/http/ConsumingInputStreamTest.java
index d55b5a0d4..33a48dce1 100644
--- a/google-http-client/src/test/java/com/google/api/client/http/ConsumingInputStreamTest.java
+++ b/google-http-client/src/test/java/com/google/api/client/http/ConsumingInputStreamTest.java
@@ -20,7 +20,6 @@
import java.io.IOException;
import java.io.InputStream;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import org.junit.Test;
diff --git a/google-http-client/src/test/java/com/google/api/client/http/UriTemplateTest.java b/google-http-client/src/test/java/com/google/api/client/http/UriTemplateTest.java
index 53376c389..1a38eeafa 100644
--- a/google-http-client/src/test/java/com/google/api/client/http/UriTemplateTest.java
+++ b/google-http-client/src/test/java/com/google/api/client/http/UriTemplateTest.java
@@ -58,13 +58,19 @@ public void testExpandTemplates_basic() {
assertTrue(requestMap.containsKey("unused"));
}
- public void testExpanTemplates_basicEncodeValue() {
+ public void testExpandTemplates_basicEncodeValue() {
SortedMap requestMap = Maps.newTreeMap();
requestMap.put("abc", "xyz;def");
assertEquals(";abc=xyz%3Bdef", UriTemplate.expand("{;abc}", requestMap, false));
assertEquals("xyz;def", UriTemplate.expand("{+abc}", requestMap, false));
}
+ public void testExpandTemplates_encodeSpace() {
+ SortedMap requestMap = Maps.newTreeMap();
+ requestMap.put("abc", "xyz def");
+ assertEquals(";abc=xyz%20def", UriTemplate.expand("{;abc}", requestMap, false));
+ }
+
public void testExpandTemplates_noExpansionsWithQueryParams() {
SortedMap requestMap = Maps.newTreeMap();
requestMap.put("abc", "xyz");
diff --git a/google-http-client/src/test/java/com/google/api/client/util/escape/CharEscapersTest.java b/google-http-client/src/test/java/com/google/api/client/util/escape/CharEscapersTest.java
index 0ad3d1e58..0a4e08809 100644
--- a/google-http-client/src/test/java/com/google/api/client/util/escape/CharEscapersTest.java
+++ b/google-http-client/src/test/java/com/google/api/client/util/escape/CharEscapersTest.java
@@ -38,12 +38,11 @@ public void testDecodeUri_IllegalArgumentException() {
}
private void subtestDecodeUri_IllegalArgumentException(String input) {
- boolean thrown = false;
try {
CharEscapers.decodeUriPath(input);
- } catch (IllegalArgumentException e) {
- thrown = true;
+ fail();
+ } catch (IllegalArgumentException expected) {
+ assertNotNull(expected.getMessage());
}
- assertTrue(thrown);
}
}
diff --git a/pom.xml b/pom.xml
index aae5f7d58..eeb364004 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
com.google.http-client
google-http-client-parent
- 1.34.1
+ 1.34.2
pom
Parent for the Google HTTP Client Library for Java
Google HTTP Client Library for Java
@@ -544,13 +544,13 @@
- google-api-java-client/google-api-client-assembly/android-properties (make the filenames match the version here)
- Internally, update the default features.json file
-->
- 1.34.1
+ 1.34.2
1.9.71
UTF-8
3.0.2
2.8.6
2.10.2
- 3.11.1
+ 3.11.3
28.2-android
1.1.4c
1.2
diff --git a/samples/dailymotion-simple-cmdline-sample/pom.xml b/samples/dailymotion-simple-cmdline-sample/pom.xml
index f5c1c9e81..a735456a7 100644
--- a/samples/dailymotion-simple-cmdline-sample/pom.xml
+++ b/samples/dailymotion-simple-cmdline-sample/pom.xml
@@ -4,7 +4,7 @@
com.google.http-client
google-http-client-parent
- 1.34.1
+ 1.34.2
../../pom.xml
dailymotion-simple-cmdline-sample
diff --git a/versions.txt b/versions.txt
index 4d2439e82..fef459c2e 100644
--- a/versions.txt
+++ b/versions.txt
@@ -1,17 +1,17 @@
# Format:
# module:released-version:current-version
-google-http-client:1.34.1:1.34.1
-google-http-client-bom:1.34.1:1.34.1
-google-http-client-parent:1.34.1:1.34.1
-google-http-client-android:1.34.1:1.34.1
-google-http-client-android-test:1.34.1:1.34.1
-google-http-client-apache-v2:1.34.1:1.34.1
-google-http-client-appengine:1.34.1:1.34.1
-google-http-client-assembly:1.34.1:1.34.1
-google-http-client-findbugs:1.34.1:1.34.1
-google-http-client-gson:1.34.1:1.34.1
-google-http-client-jackson2:1.34.1:1.34.1
-google-http-client-protobuf:1.34.1:1.34.1
-google-http-client-test:1.34.1:1.34.1
-google-http-client-xml:1.34.1:1.34.1
+google-http-client:1.34.2:1.34.2
+google-http-client-bom:1.34.2:1.34.2
+google-http-client-parent:1.34.2:1.34.2
+google-http-client-android:1.34.2:1.34.2
+google-http-client-android-test:1.34.2:1.34.2
+google-http-client-apache-v2:1.34.2:1.34.2
+google-http-client-appengine:1.34.2:1.34.2
+google-http-client-assembly:1.34.2:1.34.2
+google-http-client-findbugs:1.34.2:1.34.2
+google-http-client-gson:1.34.2:1.34.2
+google-http-client-jackson2:1.34.2:1.34.2
+google-http-client-protobuf:1.34.2:1.34.2
+google-http-client-test:1.34.2:1.34.2
+google-http-client-xml:1.34.2:1.34.2