Repository navigation
Decode ISO-8859-1 filename* in Content-Disposition - #78
Merged
Merged
Conversation
Owner
|
Thanks! |
Contributor
Author
|
Thanks! |
3 tasks done
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.
When a server sends an RFC 5987
filename*in ISO-8859-1, the downloaded file is named after the raw percent-escapes.Before: the file is saved as
%A3%20rates.txt. After: it is saved as£ rates.txt.parseContentDispositionFilenamepasses everyfilename*value todecodeURIComponent. That function only reads UTF-8, so a Latin-1 byte such as%A3throws aURIError, and the catch returns the undecoded value. RFC 5987 requires recipients to support both UTF-8 and ISO-8859-1, and the header above is the RFC's own example. Servers that still default to Latin-1 send it this way.Change
src/main/download/probe.ts: the regex now captures the charset. Foriso-8859-1, each%XXis decoded as one Latin-1 character. UTF-8 and other charsets go through the same path as before.e2e/download.spec.ts: new case in thefile names @smoketable.How I checked
fileNameis%A3%20rates.txt) and passes with the fix.npm run lint,npm run typecheck, andnpm run format:checkpass.npm run test:e2e:smoke: 90 passed, on Linux under xvfb.