Commit 8426e3c2 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '2.0.x'

parents 6fdc5d0e dd2b0eb7
......@@ -60,17 +60,14 @@ final class TraceableHttpServletRequest implements TraceableRequest {
return new URI(urlBuffer.toString());
}
catch (URISyntaxException ex) {
String encoded = UriUtils.encode(queryString, StandardCharsets.UTF_8);
String encoded = UriUtils.encodeQuery(queryString, StandardCharsets.UTF_8);
StringBuffer urlBuffer = appendQueryString(encoded);
return URI.create(urlBuffer.toString());
}
}
private StringBuffer appendQueryString(String queryString) {
StringBuffer urlBuffer = this.request.getRequestURL();
urlBuffer.append("?");
urlBuffer.append(queryString);
return urlBuffer;
return this.request.getRequestURL().append("?").append(queryString);
}
@Override
......
......@@ -50,13 +50,13 @@ public class TraceableHttpServletRequestTests {
@Test
public void getUriWithSpecialCharactersInQueryStringShouldEncode() {
this.request.setQueryString("a=${b}");
validate("http://localhost/script?a%3D%24%7Bb%7D");
validate("http://localhost/script?a=$%7Bb%7D");
}
@Test
public void getUriWithSpecialCharactersEncodedShouldNotDoubleEncode() {
this.request.setQueryString("a%3D%24%7Bb%7D");
validate("http://localhost/script?a%3D%24%7Bb%7D");
this.request.setQueryString("a=$%7Bb%7D");
validate("http://localhost/script?a=$%7Bb%7D");
}
private void validate(String expectedUri) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment