Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1bb2967

Browse filesBrowse files
mscdexMyles Borins
authored andcommitted
http: fix non-string header value concatenation
Since headers are stored in an empty literal object ({}) instead of an object created with Object.create(null), care must be taken with property names inherited from Object. Currently there are only functions inherited, so we can safely check for existing strings instead. Fixes: #4456 PR-URL: #4460 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
1 parent 437d0e3 commit 1bb2967
Copy full SHA for 1bb2967

File tree

Expand file treeCollapse file tree

2 files changed

+6
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-2
lines changed
Open diff view settings
Collapse file

‎lib/_http_incoming.js‎

Copy file name to clipboardExpand all lines: lib/_http_incoming.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value, dest) {
159159

160160
default:
161161
// make comma-separated list
162-
if (dest[field] !== undefined) {
162+
if (typeof dest[field] === 'string') {
163163
dest[field] += ', ' + value;
164164
} else {
165165
dest[field] = value;
Collapse file

‎test/parallel/test-http-server-multiheaders.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-http-server-multiheaders.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var srv = http.createServer(function(req, res) {
1616
assert.equal(req.headers['x-bar'], 'banjo, bango');
1717
assert.equal(req.headers['sec-websocket-protocol'], 'chat, share');
1818
assert.equal(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz');
19+
assert.equal(req.headers['constructor'], 'foo, bar, baz');
1920

2021
res.writeHead(200, {'Content-Type' : 'text/plain'});
2122
res.end('EOF');
@@ -48,7 +49,10 @@ srv.listen(common.PORT, function() {
4849
['sec-websocket-protocol', 'share'],
4950
['sec-websocket-extensions', 'foo; 1'],
5051
['sec-websocket-extensions', 'bar; 2'],
51-
['sec-websocket-extensions', 'baz']
52+
['sec-websocket-extensions', 'baz'],
53+
['constructor', 'foo'],
54+
['constructor', 'bar'],
55+
['constructor', 'baz'],
5256
]
5357
});
5458
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.