Skip to content

fix: percent-encode parentheses in filename* per RFC 5987 - #607

Open
abhu85 wants to merge 1 commit into
form-data:masterfrom
abhu85:fix/572-encode-parentheses-in-filename
Open

abhu85 wants to merge 1 commit into
form-data:masterfrom
abhu85:fix/572-encode-parentheses-in-filename

Conversation

@abhu85

@abhu85 abhu85 commented Apr 29, 2026

Copy link
Copy Markdown

Summary

Percent-encode parentheses in filename* Content-Disposition header values per RFC 5987.

Problem

Parentheses ( and ) are separator characters per RFC 2616 and must be percent-encoded in filename* values per RFC 5987. Currently they are passed through unencoded, causing .NET backends (and other strict HTTP parsers) to reject the multipart request.

Solution

Add parentheses to the set of characters that are percent-encoded when generating filename* values. When a filename contains characters outside the RFC 5987 attr-char set, a filename* parameter with proper percent-encoding is emitted alongside the existing filename parameter for backward compatibility.

Test Plan

  • Filename test(1).txt produces filename*=utf-8''test%281%29.txt
  • Simple filenames (e.g. test.txt) do not get a filename* parameter
  • Spaces are encoded (e.g. my file.txt → my%20file.txt)
  • Existing tests pass
  • No breaking changes to filename (non-starred) header

Fixes #572

)

When a filename contains characters outside the RFC 5987 attr-char set
(such as parentheses, spaces, or other RFC 2616 separators), emit a
filename* parameter with proper percent-encoding alongside the existing
filename parameter for backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid Content-Disposition with FileName* containing parenthesis

1 participant