Fix issue with encoded params in UriComponentsBuilder
The fromUri method of UriComponentsBuilder used uri.getXxx() methods, which decode the URI parts causing URI parsing issues. The same method now uses uri.getRawXxx(). Issue: SPR-9317
This commit is contained in:
parent
ae9549ae13
commit
a33fe6fa0a
|
@ -260,8 +260,8 @@ public class UriComponentsBuilder {
|
|||
|
||||
this.scheme = uri.getScheme();
|
||||
|
||||
if (uri.getUserInfo() != null) {
|
||||
this.userInfo = uri.getUserInfo();
|
||||
if (uri.getRawUserInfo() != null) {
|
||||
this.userInfo = uri.getRawUserInfo();
|
||||
}
|
||||
if (uri.getHost() != null) {
|
||||
this.host = uri.getHost();
|
||||
|
@ -269,15 +269,15 @@ public class UriComponentsBuilder {
|
|||
if (uri.getPort() != -1) {
|
||||
this.port = uri.getPort();
|
||||
}
|
||||
if (StringUtils.hasLength(uri.getPath())) {
|
||||
this.pathBuilder = new FullPathComponentBuilder(uri.getPath());
|
||||
if (StringUtils.hasLength(uri.getRawPath())) {
|
||||
this.pathBuilder = new FullPathComponentBuilder(uri.getRawPath());
|
||||
}
|
||||
if (StringUtils.hasLength(uri.getQuery())) {
|
||||
if (StringUtils.hasLength(uri.getRawQuery())) {
|
||||
this.queryParams.clear();
|
||||
query(uri.getQuery());
|
||||
query(uri.getRawQuery());
|
||||
}
|
||||
if (uri.getFragment() != null) {
|
||||
this.fragment = uri.getFragment();
|
||||
if (uri.getRawFragment() != null) {
|
||||
this.fragment = uri.getRawFragment();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,17 @@ public class UriComponentsBuilderTests {
|
|||
assertEquals("Invalid result URI", uri, result.toUri());
|
||||
}
|
||||
|
||||
// SPR-9317
|
||||
|
||||
@Test
|
||||
public void fromUriEncodedQuery() throws URISyntaxException {
|
||||
URI uri = new URI("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D");
|
||||
String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0);
|
||||
String fromUriString = UriComponentsBuilder.fromUriString(uri.toString()).build().getQueryParams().get("param").get(0);
|
||||
|
||||
assertEquals(fromUri, fromUriString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromUriString() {
|
||||
UriComponents result = UriComponentsBuilder.fromUriString("http://www.ietf.org/rfc/rfc3986.txt").build();
|
||||
|
|
|
@ -12,6 +12,7 @@ Changes in version 3.2 M1
|
|||
* fix concurrency issue in AnnotationMethodHandlerExceptionResolver
|
||||
* fix case-sensitivity issue with some containers on access to 'Content-Disposition' header
|
||||
* add Servlet 3.0 based async support
|
||||
* fix issue with encoded params in UriComponentsBuilder
|
||||
|
||||
Changes in version 3.1.1 (2012-02-16)
|
||||
-------------------------------------
|
||||
|
|
Loading…
Reference in New Issue