Skip to content

Commit

Permalink
Fix wrong URL encoding in watcher HTTP client
Browse files Browse the repository at this point in the history
The test assumption was calling the wrong method resulting in a URL
encoding before returning the data.

Closes elastic#44970 (for real this time)
  • Loading branch information
spinscale committed Aug 23, 2019
1 parent eef8235 commit 6528afa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,11 @@ static Tuple<HttpHost, URI> createURI(HttpRequest request) {
String part = pathParts[i];
boolean isLast = i == pathParts.length - 1;
if (Strings.isEmpty(part) == false) {
String appendPart = part;
unescapedPathParts.add(URLDecoder.decode(part, StandardCharsets.UTF_8.name()));
boolean appendSlash = isPathEndsWithSlash && isLast;
if (appendSlash) {
appendPart += "/";
unescapedPathParts.add("");
}
unescapedPathParts.add(URLDecoder.decode(appendPart, StandardCharsets.UTF_8.name()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ public void testCreateUri() throws Exception {
private void assertCreateUri(String uri, String expectedPath) {
final HttpRequest request = HttpRequest.builder().fromUrl(uri).build();
final Tuple<HttpHost, URI> tuple = HttpClient.createURI(request);
assertThat(tuple.v2().getPath(), is(expectedPath));
assertThat(tuple.v2().getRawPath(), is(expectedPath));
}

public static ClusterService mockClusterService() {
Expand Down

0 comments on commit 6528afa

Please sign in to comment.