Skip to content

Mustache templates return with ISO-8859-1 charset rather than UTF-8 in Content-Type response header #44053

@mmorrisontx

Description

@mmorrisontx

The spring boot mustache view resolver accepts a charset parameter (via MustacheProperties), but that parameter is only used by the template loader, it is not used as part of the response content type. The default returned content type is text/html (with no charset), since that's the content type set on the ViewResolver in MustacheServletWebConfiguration.

In spring boot 2, this fell back on jetty's default implied charset list, via jetty's MimeTypes.getCharsetInferredFromContentType. By default, jetty returns utf-8 for text/html, which effectively made the response headers contain Content-Type: text/html;charset=utf-8. All was happy.

However, in spring boot 3, this added line totally wipes out jetty's inferred charset list. This causes jetty to fall back to it's hard-coded last resort charset, ISO-8859-1 (see jetty's ServletContextResponse ).

This means that in spring boot 3, all mustache templates are rendered using utf8, but return an iso-8859-1 content type header, which is incorrect and breaks all non-latin characters.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions