fix lack of escaping of filename in Content-Disposition#545
Draft
motoyasu-saburi wants to merge 4 commits intoform-data:masterfrom
Draft
fix lack of escaping of filename in Content-Disposition#545motoyasu-saburi wants to merge 4 commits intoform-data:masterfrom
motoyasu-saburi wants to merge 4 commits intoform-data:masterfrom
Conversation
ljharb
requested changes
Sep 19, 2024
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Author
|
I'm Sorry for the delay in getting back to you. I'm having problems with CI in Automatic Rebase. |
Member
|
Don't worry about that check; that's failing because you merged the upstream changes instead of rebased them. I can rebase the PR later. |
ljharb
requested changes
Nov 23, 2024
| contentDisposition = 'filename="' + filename + '"'; | ||
| // Escaping to prevent CRLF Injection / tampering with invalid fields. | ||
| // https://html.spec.whatwg.org/#multipart-form-data | ||
| var escapedFilename = filename.replaceAll('"', '%22') |
Member
There was a problem hiding this comment.
unfortunately replaceAll isn't available in all engines we support. what about this?
Suggested change
| var escapedFilename = filename.replaceAll('"', '%22') | |
| var escapedFilename = filename.replace(/"/g, '%22') |
| body += chunk; | ||
| }); | ||
| req.on('end', function () { | ||
| assert(body.includes(escapedContentDispositionHeader), 'Expects encode "filename" field'); |
Member
There was a problem hiding this comment.
Suggested change
| assert(body.includes(escapedContentDispositionHeader), 'Expects encode "filename" field'); | |
| assert(body.indexOf(escapedContentDispositionHeader) >= 0, 'Expects encode "filename" field'); |
similarly, includes isn't available in everything either.
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.
Fixes #546