Description
This is a simple junit test which fails but should work according to https://tools.ietf.org/html/rfc3986#section-3.3 because +
sign is allowed to be used within a path component and has no special meaning when used within a path component:
@Test public void testGenericUrl() throws URISyntaxException { final URI uri = new URI("http://foo.bar/path+with+plus"); final GenericUrl genericUrl = new GenericUrl(uri); Assert.assertEquals("/path+with+plus", genericUrl.getRawPath()); Assert.assertEquals(ImmutableList.of("", "path+with+plus"), genericUrl.getPathParts()); }
This bug is related to #255 but shows different behaviour. We are using google-http-client
library version 1.23.0
:
<dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client</artifactId> <version>1.23.0</version> </dependency>
From the first glance on sources, it looks like there is a bug inside toPathParts
methods implementation on line 550: https://github.com/google/google-http-java-client/blob/110b3ab6fa7838dbe9926038427c712db9ed8aae/google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java#L545-L553
There a call is made to CharEscapers.decodeUri
which is invalid, because JavaDoc of this method explicitly states that it must not be used for path segments (see the second paragraph): https://github.com/google/google-http-java-client/blob/110b3ab6fa7838dbe9926038427c712db9ed8aae/google-http-client/src/main/java/com/google/api/client/util/escape/CharEscapers.java#L78-L90