-
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.
If a port is not a number, throw rather than treating the `:` that delineates the port as part of the path. This is consistent with WHATWG URL and also mitigates hostname-spoofing. Concerns about hostname-spoofing were raised and presented in excellent detail by pyozzi-toss ([email protected]/Security-Tech Team in Toss). PR-URL: #45012 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
3 changed files
with
18 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -865,22 +865,6 @@ const parseTests = { | |
href: 'http://a%0D%22%20%09%0A%3C\'b:b@c/%0D%0Ad/e?f' | ||
}, | ||
|
||
// Git urls used by npm | ||
'git+ssh://[email protected]:npm/npm': { | ||
protocol: 'git+ssh:', | ||
slashes: true, | ||
auth: 'git', | ||
host: 'github.com', | ||
port: null, | ||
hostname: 'github.com', | ||
hash: null, | ||
search: null, | ||
query: null, | ||
pathname: '/:npm/npm', | ||
path: '/:npm/npm', | ||
href: 'git+ssh://[email protected]/:npm/npm' | ||
}, | ||
|
||
'https://*': { | ||
protocol: 'https:', | ||
slashes: true, | ||
|
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 |
---|---|---|
|
@@ -74,3 +74,15 @@ if (common.hasIntl) { | |
(e) => e.code === 'ERR_INVALID_URL', | ||
'parsing http://\u00AD/bad.com/'); | ||
} | ||
|
||
{ | ||
const badURLs = [ | ||
'https://evil.com:.example.com', | ||
'git+ssh://[email protected]:npm/npm', | ||
]; | ||
badURLs.forEach((badURL) => { | ||
assert.throws(() => { url.parse(badURL); }, | ||
(e) => e.code === 'ERR_INVALID_URL', | ||
`parsing ${badURL}`); | ||
}); | ||
} |