Skip to content

PathVariable encoding fails if request charset is not set [SPR-11474] #16099

@spring-projects-issues

Description

@spring-projects-issues

Mats Svensson opened SPR-11474 and commented

Code below

// this works, tagId is properly decoded
@RequestMapping(value = "/tag/{tagId}", method = RequestMethod.PUT)
public @ResponseBody SourceTag updateTag(@RequestBody SourceTag newTag, @PathVariable("tagId") String tagId) {
    return sourceService.updateTag(new SourceTag(tagId), newTag);
}
// but here it fails!
@RequestMapping(value = "/tag/{tagId}", method = RequestMethod.DELETE)
public @ResponseBody SourceTag updateTag(@PathVariable("tagId") String tagId) {
    // something
}

When trying to access
/tag/mmm%C3%A6%C3%A6%C3%B8%C3%A5 as PUT with an object, the
pathvariable tagId contains the value "mmmææøå"

But when accessing
/tag/mmm%C3%A6%C3%A6%C3%B8%C3%A5 as DELETE
the pathvariable tagId contains the value "mmmææøå"

After testing, the problem seems not to be using DELETE instead of PUT, but having a @RequestBody and not having one.


Affects: 3.2.8, 4.0.2

Issue Links:

Referenced from: commits spring-attic/spring-framework-issues@d2cb761, spring-attic/spring-framework-issues@1e4ef2b

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