-
Notifications
You must be signed in to change notification settings - Fork 305
fix lack of escaping of filename in Content-Disposition #545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix lack of escaping of filename in Content-Disposition #545
Conversation
Co-authored-by: Jordan Harband <ljharb@gmail.com>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
I'm Sorry for the delay in getting back to you. I'm having problems with CI in Automatic Rebase. |
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. |
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately replaceAll isn't available in all engines we support. what about this?
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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Fixes #546