micronaut-projects / micronaut-views

Micronaut Integration with Server Side View Rendering
Apache License 2.0
28 stars 32 forks source link

No charset encoding specified on view responses #752

Closed mikehearn closed 2 months ago

mikehearn commented 3 months ago

Expected Behavior

Unless otherwise specified, HTTP responses from Micronaut (Views) should declare that they are in UTF-8 in the Content-Type header.

Actual Behaviour

No encoding is specified, leaving the browser to guess, and sometimes it guesses wrong.

Steps To Reproduce

  1. Make a view that includes the output of something like DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).format(LocalDateTime.now()) which should yield a unicode NNBSP character before the "AM" or "PM" part.
  2. Load it in Chrome.
  3. Observe mojibake
  4. Add a <meta charset="utf-8"/> tag to the header.
  5. Observe that it's now fixed.

Environment Information

macOS 14, Chrome

Example Application

No response

Version

4.3.6

timyates commented 2 months ago

Done in https://github.com/micronaut-projects/micronaut-views/pull/801 for Micronaut 4.5.0