-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-f772-66g8-q5h3
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict' | ||
|
||
const { createServer } = require('http') | ||
const { test } = require('tap') | ||
const { request, errors } = require('..') | ||
|
||
test('should validate content-type CRLF Injection', (t) => { | ||
t.plan(2) | ||
|
||
const server = createServer((req, res) => { | ||
t.fail('should not receive any request') | ||
res.statusCode = 200 | ||
res.end('hello') | ||
}) | ||
|
||
t.teardown(server.close.bind(server)) | ||
|
||
server.listen(0, async () => { | ||
try { | ||
await request(`http://localhost:${server.address().port}`, { | ||
method: 'GET', | ||
headers: { | ||
'content-type': 'application/json\r\n\r\nGET /foo2 HTTP/1.1' | ||
}, | ||
}) | ||
t.fail('request should fail') | ||
} catch (e) { | ||
t.type(e, errors.InvalidArgumentError) | ||
t.equal(e.message, 'invalid content-type header') | ||
} | ||
}) | ||
}) |