Skip to content

MediaType.parseMediaTypes fails if the input contains a comma [SPR-17459] #21991

@spring-projects-issues

Description

@spring-projects-issues

Fabian Kürten opened SPR-17459 and commented

For the class org.springframework.http.MediaType

Parsing a list of media types fails if a media type contains a comma ",".
For example this fails with InvalidMediaTypeException:

MediaType.parseMediaTypes("foo/bar;param=\",\"");

While the comma is the separator for different media types in a header my understanding is that it is legal to use tspecial characters (like comma) inside a quoted string.
However the implementation of parseMediaTypes tokenizes blindly by comma, ignoring quotes. The resulting parts are invalid media types (ends with an open quote) which leads to the exception.
 


Affects: 5.0.4, 5.1.2

Referenced from: commits f4b05dc, 7bbd4c6, ba3fef3

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions