Closed
Description
Dave Syer opened SPR-10172 and commented
UriComponents.Type.QUERY_PARAM does not match spec, in particular it does not allow the relatively common usage of "+" to encode " " (SPACE). So you get a nasty error with ServletUriComponentsBuilder.fromRequest
whenever the query is (legally) encoded with "+" for " ". An ugly workaround is to do this:
UriComponents uri = ServletUriComponentsBuilder.fromRequest(request).replaceQuery(request.getQueryString().replace("+", "%20")).build(true);
String query = uri.getQuery().replace("%20", "+");
return ServletUriComponentsBuilder.fromUri(uri.toUri()).replaceQuery(query).build(true).toString();
Affects: 3.1.2
Issue Links:
- UriComponentBuilder doesn't work with encoded HTTP URL having '+'. [SPR-14828] #19394 UriComponentBuilder doesn't work with encoded HTTP URL having '+'. ("duplicates")
5 votes, 7 watchers