fix(core): parse spec-legal content-disposition filename forms - #52
Merged
Merged
Conversation
getFilenameFromContentDisposition now handles the unquoted token form (filename=report.pdf), anchors param names so bogus params like xfilename*= or creation-filename= no longer match, and parses the RFC 8187 ext-value charset/language prefix instead of only stripping a literal utf-8'' string. generateContentDisposition gains an optional 'inline' | 'attachment' type parameter (default 'inline').
@standardserver/aws-lambda
@standardserver/bun
@standardserver/core
@standardserver/deno
@standardserver/fastify
@standardserver/fetch
@standardserver/node
@standardserver/peer
@standardserver/shared
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getFilenameFromContentDisposition previously returned undefined for the unquoted token form, matched param names as substrings, and only understood a literal utf-8'' prefix. Spec-compliant peers sending plain filename=report.pdf had their uploads fall back to the name "blob" in every adapter, and ext-values with a charset or language tag came back garbled. generateContentDisposition also gains an optional 'inline' | 'attachment' type parameter (default 'inline', so existing output is unchanged).
Fixes
attachment; filename=report.pdfnow yieldsreport.pdfinstead ofundefined— fetch/node/aws-lambda/peer adapters no longer fall back toblobfor these headers.;, soxfilename*=evilno longer matches and can no longer shadow a legitimatefilename="good.txt"; same forcreation-filename=in the quoted branch.charset'lang'value:filename*=utf-8'en'%E2%82%AC.txtdecodes to€.txtinstead of keeping theutf-8'en'prefix. Only utf-8/us-ascii values are percent-decoded; unsupported charsets fall through to the plainfilenameparam.filename*=%XX...values still percent-decode (lenient path pinned by an existing test).Notes for reviewers
;inside a quoted filename value is still treated as a param delimiter (pre-existing, also affects generate→parse round-trips of filenames containing";); left for a follow-up since fixing it conflicts with the malformed-input expectation tested at utils.test.ts:35.Testing