Skip to content

Multipart processing @Body annotation decodes to string using incorrect charset #829

@tfield

Description

@tfield

Expected Behavior

When using the @Body annotation to extract multipart parameters into a Map<String,List>, the list of parameter values should be decoded to strings as UTF-8

Actual Behaviour

The list of parameter values is decoded to strings using latin1. The strings need to be decoded to bytes then re-converted to strings using utf-8.

Steps To Reproduce

See repository linked below. But to roll your own:

  • create a form that posts strings to a controller using multipart/form-data
  • add non-latin1 characters to the string (e.g. smart quotes)
  • decode values using @Body Map<String,List>
  • observe incorrect decoding
  • convert to bytes using latin1
  • convert back to string using utf8
  • observe correct decoding

Environment Information

  • Micronaut 4.4.2
  • Micronaut Servlet (Tomcat)
  • Multipart enabled
  • MacOS 15.1

Example Application

https://github.com/tfield/micronaut-servlet-multipart

Version

4.4.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions