-
Notifications
You must be signed in to change notification settings - Fork 30k
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
http: reject control characters in http.request() #8923
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
'use strict'; | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var http = require('http'); | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
|
||
assert.throws(function() { | ||
// Path with spaces in it should throw. | ||
http.get({ path: 'bad path' }, common.fail); | ||
}, /contains unescaped characters/); | ||
function* bad() { | ||
for (let i = 0; i <= 32; i += 1) | ||
yield 'bad' + String.fromCharCode(i) + 'path'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: it doesn't add any real value but what about using a template literal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially had that but I felt it was less readable than concatenation. Consider: yield 'bad' + String.fromCharCode(i) + 'path'; Vs. yield `bad${String.fromCharCode(i)}path`; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah no big deal. |
||
} | ||
|
||
for (const path of bad()) { | ||
assert.throws(() => http.get({ path }, common.fail), | ||
/contains unescaped characters/); | ||
} |
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.
RangeError
?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.
Ack, but for a different PR because people may want to be careful and consider that
semver-major
?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.
Hmm, I think this would be a unecessary breaking change if we consider error types as API. So, LGTM as-is.