Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ static URIBuilder normalize(final URIBuilder builder) {
}
}
builder.setFragment(null);
// Decode '+' in the query as a blank, as form-urlencoded servers do, so that
// the re-encoded query keeps '+' (a blank) and '%2B' (a literal plus) apart
builder.setPlusAsBlank(true);
builder.optimize();
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,16 @@ void testGetURIWithQueryParameters() {
"/full_episodes?foo=bar")));
}

@Test
void testPlusAndEncodedPlusInQueryAreNotEquivalent() {
final HttpHost host = new HttpHost("foo.example.com");
final HttpRequest req1 = new BasicHttpRequest("GET", "/search?q=a+b");
final HttpRequest req2 = new BasicHttpRequest("GET", "/search?q=a%2Bb");
final HttpRequest req3 = new BasicHttpRequest("GET", "/search?q=a%20b");
Assertions.assertNotEquals(generateKey(host, req1), generateKey(host, req2));
Assertions.assertEquals(generateKey(host, req1), generateKey(host, req3));
}

private static Iterator<Header> headers(final Header... headers) {
return new BasicHeaderIterator(headers, null);
}
Expand Down
Loading