-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http,https,tls: switch to WHATWG URL parser
This switches the url parser from `url.parse()` to the WHATWG URL parser while keeping `url.parse()` as fallback. Also add tests for invalid url deprecations and correct hostname checks. PR-URL: #20270 Fixes: #19468 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
- Loading branch information
Showing
13 changed files
with
149 additions
and
27 deletions.
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
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
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
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
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,28 @@ | ||
/* eslint-disable node-core/crypto-check */ | ||
// Flags: --expose-internals | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
const { outHeadersKey } = require('internal/http'); | ||
|
||
const http = require('http'); | ||
const modules = { http }; | ||
|
||
if (common.hasCrypto) { | ||
const https = require('https'); | ||
modules.https = https; | ||
} | ||
|
||
Object.keys(modules).forEach((module) => { | ||
const doNotCall = common.mustNotCall( | ||
`${module}.request should not connect to ${module}://example.com%60x.example.com` | ||
); | ||
const req = modules[module].request(`${module}://example.com%60x.example.com`, doNotCall); | ||
assert.deepStrictEqual(req[outHeadersKey].host, [ | ||
'Host', | ||
'example.com`x.example.com', | ||
]); | ||
req.abort(); | ||
}); |
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,33 @@ | ||
/* eslint-disable node-core/crypto-check */ | ||
|
||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const http = require('http'); | ||
const modules = { http }; | ||
|
||
const deprecations = [ | ||
['The provided URL http://[www.nodejs.org] is not a valid URL, and is supported ' + | ||
'in the http module solely for compatibility.', | ||
'DEP0109'], | ||
]; | ||
|
||
if (common.hasCrypto) { | ||
const https = require('https'); | ||
modules.https = https; | ||
deprecations.push( | ||
['The provided URL https://[www.nodejs.org] is not a valid URL, and is supported ' + | ||
'in the https module solely for compatibility.', | ||
'DEP0109'], | ||
); | ||
} | ||
|
||
common.expectWarning('DeprecationWarning', deprecations); | ||
|
||
Object.keys(modules).forEach((module) => { | ||
const doNotCall = common.mustNotCall( | ||
`${module}.request should not connect to ${module}://[www.nodejs.org]` | ||
); | ||
modules[module].request(`${module}://[www.nodejs.org]`, doNotCall).abort(); | ||
}); |
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
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