Skip to content

Support reading percent-encoded multipart/form-data filenames on the server #1496

Closed

Description

@pjfanning

Current behavior

When a server receives a multipart/form-data part, Multipart.FormData.BodyPart.filename (Java: getFilename) returns the raw filename parameter. An RFC 5987 filename* parameter is decoded and replaces filename, but a percent-encoded plain filename is returned as-is.

RFC 7578 section 4.2 forbids filename* in form-data and allows senders to percent-encode non-ASCII filenames in the plain filename parameter instead. Such a part, e.g. filename="caf%C3%A9.txt", is exposed as the literal caf%C3%A9.txt, and Pekko HTTP has no way to recover café.txt.

#1494 adds an outgoing PercentEncoded filename option to the client side, so without matching server-side support, Pekko client to Pekko server does not round-trip.

Expected behavior

Applications should be able to opt in to reading a percent-decoded filename. This cannot be the default, because a literal % is valid in filenames (browsers do not encode it), so decoding every value would change existing names such as 100%25.txt.

Suggested scope:

  • An opt-in accessor on the Scala and Java form-data body part that returns the UTF-8 percent-decoded filename.
  • Fall back to the raw filename when the value is not valid percent-encoded UTF-8 (e.g. 100%.txt).
  • Keep filename / getFilename unchanged.
  • Document that the decoded value is untrusted client input and should not be used as a file system path without sanitizing it.

Refs #1494, #1478.

Activity

  1. added this to the 2.1.0 milestone on Nov 18, 2026
  2. added a commit that references this issue on Nov 18, 2026
    4d7edbb
  3. added a commit that references this issue on Nov 18, 2026
    18ad1da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions