Merge branch '2.0.x'

pull/13545/merge
Stephane Nicoll 6 years ago
commit 8426e3c2c9

@ -60,17 +60,14 @@ final class TraceableHttpServletRequest implements TraceableRequest {
return new URI(urlBuffer.toString()); return new URI(urlBuffer.toString());
} }
catch (URISyntaxException ex) { catch (URISyntaxException ex) {
String encoded = UriUtils.encode(queryString, StandardCharsets.UTF_8); String encoded = UriUtils.encodeQuery(queryString, StandardCharsets.UTF_8);
StringBuffer urlBuffer = appendQueryString(encoded); StringBuffer urlBuffer = appendQueryString(encoded);
return URI.create(urlBuffer.toString()); return URI.create(urlBuffer.toString());
} }
} }
private StringBuffer appendQueryString(String queryString) { private StringBuffer appendQueryString(String queryString) {
StringBuffer urlBuffer = this.request.getRequestURL(); return this.request.getRequestURL().append("?").append(queryString);
urlBuffer.append("?");
urlBuffer.append(queryString);
return urlBuffer;
} }
@Override @Override

@ -50,13 +50,13 @@ public class TraceableHttpServletRequestTests {
@Test @Test
public void getUriWithSpecialCharactersInQueryStringShouldEncode() { public void getUriWithSpecialCharactersInQueryStringShouldEncode() {
this.request.setQueryString("a=${b}"); this.request.setQueryString("a=${b}");
validate("http://localhost/script?a%3D%24%7Bb%7D"); validate("http://localhost/script?a=$%7Bb%7D");
} }
@Test @Test
public void getUriWithSpecialCharactersEncodedShouldNotDoubleEncode() { public void getUriWithSpecialCharactersEncodedShouldNotDoubleEncode() {
this.request.setQueryString("a%3D%24%7Bb%7D"); this.request.setQueryString("a=$%7Bb%7D");
validate("http://localhost/script?a%3D%24%7Bb%7D"); validate("http://localhost/script?a=$%7Bb%7D");
} }
private void validate(String expectedUri) { private void validate(String expectedUri) {

Loading…
Cancel
Save