Skip to content

GET query parameters containing comma are not properly URL decoded #29411

Closed as not planned
@ionel-sirbu-crunch

Description

@ionel-sirbu-crunch

Affects: Spring Boot 2.7.5


Hello,

I recently realised that one of my GET endpoints has issues if the values passed in the query params contain commas (,).
Basically, I expect to be able to embed a comma into a single value being passed into a query param, however, the receiving end must define the data type as List<String> & Spring splits the value into 2 rather than keeping it in one piece.

To give an example, assume you have this endpoint:

@GetMapping
public ResponseEntity<List<String>> getSomeResource(@RequestParam("res") List<String> resources) {
    return ResponseEntity.ok(resources);
}

If you hit it with this request:

curl http://localhost:8080/test?res=xx%2Cyy

then you get back ["xx","yy"], which is exactly the same result as requesting curl http://localhost:8080/test?res=xx,yy, but I expect to get back a list with a single element instead, ["xx,yy"].

Demo app can be found here.

Thank you very much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webIssues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions