Skip to content

Ensure parsing/toString symmetry in ContentDisposition name - #37133

Closed
yashsiwacha wants to merge 1 commit into
spring-projects:mainfrom
yashsiwacha:fix/issue-37064-content-disposition-symmetry
Closed

Ensure parsing/toString symmetry in ContentDisposition name#37133
yashsiwacha wants to merge 1 commit into
spring-projects:mainfrom
yashsiwacha:fix/issue-37064-content-disposition-symmetry

Conversation

@yashsiwacha

Copy link
Copy Markdown

Closes gh-37064

Overview

Currently, the parsing/toString() process for the name parameter in ContentDisposition is not symmetric when it comes to quoted-pairs (characters like \" and \\).

While ContentDisposition already correctly encodes and decodes quoted-pairs for the filename parameter, the name parameter was written and read as a raw quoted string. As a result, formatting a name containing a quote or backslash produces malformed HTTP headers, and parsing them back yields corrupted names containing unescaped backslashes.

Changes

  • Formatting: Updated ContentDisposition.toString() to encode the name parameter using encodeQuotedPairs(this.name).
  • Parsing: Updated ContentDisposition.parse() to decode the parsed name value using decodeQuotedPairs(value) if a backslash is present.
  • Testing: Added formatAndParseWithNameWithQuotes in ContentDispositionTests to assert formatting and parsing symmetry under nested quotes and backslashes.

Signed-off-by: Yash Siwach <yashsiwach07@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 13, 2026
@bclozel

bclozel commented Aug 13, 2026

Copy link
Copy Markdown
Member

See #37069 (comment)

@bclozel bclozel closed this Aug 13, 2026
@bclozel bclozel added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure parsing/tostring symmetry in ContentDisposition

3 participants