Skip to content

fix(http): read ISO-8859-1 filename* and escaped quotes in Content-Disposition - #629

Merged
linroid merged 1 commit into
mainfrom
fix/http-content-disposition-charsets
Oct 23, 2026
Merged

linroid merged 1 commit into
mainfrom
fix/http-content-disposition-charsets

Conversation

@linroid

@linroid linroid commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Found while testing Content-Disposition variants with the CLI against a local server:

Header Before After
attachment; filename*=ISO-8859-1''r%E9sum%E9.pdf named after the URL (cd) résumé.pdf
attachment; filename="a\"b.txt" named after the URL (cd) a_b.txt (the quote is sanitized)
raw UTF-8 filename="résumé 中文.pdf", unquoted, filename* + filename correct unchanged

Why

  • fromContentDisposition only read filename* with UTF-8'', but RFC 5987 also allows ISO-8859-1, which older servers send and browsers decode.
  • The quoted-string pattern "([^"]+)" stopped at the escaped quote, so filename="a\"b.txt" matched as a\, which the sanitizer reduced to nothing. RFC 6266 quoted strings escape with backslashes.

What changes

  • filename* accepts UTF-8 or ISO-8859-1 (new percentDecodeLatin1).
  • filename="…" is read as a quoted string: \" and \\ stand for " and \. Other backslashes are kept, so a Windows path an old browser sent unescaped (C:\Users\x\file.txt) still reduces to file.txt.

Verification

  • ketch from this branch saves the first two headers as résumé.pdf and a_b.txt.
  • New DefaultFileNameResolverTest cases: contentDisposition_isoLatinExtendedFilename_isDecoded and contentDisposition_quotedStringEscapes_areRead (with the Windows-path case).
  • ./gradlew :library:core:jvmTest --tests '*DefaultFileNameResolverTest*' --tests '*DownloadExecutionDestPathTest*' --tests '*HttpDownloadSourceTest*' passes.

…sposition

filename*=ISO-8859-1''r%E9sum%E9.pdf, which RFC 5987 allows beside UTF-8,
was ignored and the file named after its URL; so was a quoted filename
holding an escaped quote (filename="a\"b.txt"), whose match stopped at
the backslash. Both are read now; other backslashes in a quoted filename
stay, so Windows paths old browsers sent still keep their last segment.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T16:43:24.993941Z 5248a01 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 199 files  ±0   2 227 suites  ±0   57m 33s ⏱️ +45s
15 339 tests +8  15 071 ✅ +8  268 💤 ±0  0 ❌ ±0 
18 696 runs  +8  18 428 ✅ +8  268 💤 ±0  0 ❌ ±0 

Results for commit 5248a01. ± Comparison against base commit e6d2fe1.

@linroid
linroid merged commit 8fdf16e into main Oct 23, 2026
15 checks passed
@linroid
linroid deleted the fix/http-content-disposition-charsets branch October 23, 2026 17:41
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.

1 participant