Skip to content

request body of application/x-www-form-urlencoded HTTP request is encoded wrong in @RequestBody parameterΒ #33523

@tompson

Description

@tompson

Affects: 6.1.12


the content of a parameter annotated with @RequestBody should contain the body of the request as sent to the server but it is encoded wrong

The following example controller:

@RestController
public class AsteriskController {

    private static final Logger log = LoggerFactory.getLogger(AsteriskController.class);

    @PostMapping(value = "/message", consumes = "application/x-www-form-urlencoded")
    public void message(@RequestBody String body) {
        log.info("Received body: {}", body);
    }
}

when sent the following request

curl -L 'localhost:8080/message' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'payload=%7B%22text%22%3A%22%2ABe%2Bnotified%2A%22%7D'

prints out

Received body: payload=%7B%22text%22%3A%22*Be%2Bnotified*%22%7D

whereas it should print

Received body: payload=%7B%22text%22%3A%22%2ABe%2Bnotified%2A%22%7D

The * encoded as %2A is decoded and encoded wrong somehow in the filter chain when parsing the request

Metadata

Metadata

Assignees

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