Closed
Description
Joseph Mason opened SPR-16718 and commented
I noticed this issue after upgrading from Spring 4 to Spring 5. Basically, certain API calls we had been making with no issues before starting failing. Looking into it deeper, the issue is that the UriComponentsBuilder
is not functioning the same as it was before. It's not clear to me if this is a bug or if there's a different way that this class needs to be used now.
This test passes when using Spring 4:
@Test
public void shouldEncodePlusSignInUrlProperly() throws Exception {
//given
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.newInstance()
.scheme("https")
.host("test.com")
.port(443);
//when
uriComponentsBuilder.queryParam("foo", "bar+");
//then
assertThat(uriComponentsBuilder.buildAndExpand().encode().toString()).isEqualTo("https://test.com:443?foo=bar%2B");
}
But when using Spring 5, it will fail. Instead of this:
https://test.com:443?foo=bar%2B
it produces:
https://test.com:443?foo=bar+
Affects: 5.0 GA, 5.0.1, 5.0.2, 5.0.3, 5.0.4, 5.0.5
Issue Links:
- UriComponentBuilder doesn't work with encoded HTTP URL having '+'. [SPR-14828] #19394 UriComponentBuilder doesn't work with encoded HTTP URL having '+'.
- [docs] Explain URI template encoding [SPR-16422] #20968 [docs] Explain URI template encoding
- Support stricter encoding of URI variables in UriComponents [SPR-17039] #21577 Support stricter encoding of URI variables in UriComponents ("is superseded by")
0 votes, 6 watchers