Skip to content

UriComponents.Type.QUERY_PARAM does not match spec [SPR-10172] #14805

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

5 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: duplicateA duplicate of another issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions