| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6663264 commit 3aaa2eb
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3548,6 +3548,9 @@ issued for `url.parse()` vulnerabilities. | |||
| 3548 | 3548 | ||
| 3549 | 3549 | <!-- YAML | |
| 3550 | 3550 | changes: | |
| 3551 | + - version: REPLACEME | ||
| 3552 | + pr-url: https://github.com/nodejs/node/pull/58617 | ||
| 3553 | + description: End-of-Life. | ||
| 3551 | 3554 | - version: | |
| 3552 | 3555 | - v20.0.0 | |
| 3553 | 3556 | pr-url: https://github.com/nodejs/node/pull/45526 | |
@@ -3559,11 +3562,11 @@ changes: | |||
| 3559 | 3562 | description: Documentation-only deprecation. | |
| 3560 | 3563 | --> | |
| 3561 | 3564 | ||
| 3562 | - Type: Runtime | ||
| 3565 | + Type: End-of-Life | ||
| 3563 | 3566 | ||
| 3564 | - [`url.parse()`][] accepts URLs with ports that are not numbers. This behavior | ||
| 3565 | - might result in host name spoofing with unexpected input. These URLs will throw | ||
| 3566 | - an error in future versions of Node.js, as the [WHATWG URL API][] does already. | ||
| 3567 | + [`url.parse()`][] used to accept URLs with ports that are not numbers. This | ||
| 3568 | + behavior might result in host name spoofing with unexpected input. These URLs | ||
| 3569 | + will throw an error (which the [WHATWG URL API][] also does). | ||
| 3567 | 3570 | ||
| 3568 | 3571 | ### DEP0171: Setters for `http.IncomingMessage` headers and trailers | |
| 3569 | 3572 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,7 @@ const querystring = require('querystring'); | |||
| 41 | 41 | const { | |
| 42 | 42 | ERR_INVALID_ARG_TYPE, | |
| 43 | 43 | ERR_INVALID_URL, | |
| 44 | + ERR_INVALID_ARG_VALUE, | ||
| 44 | 45 | } = require('internal/errors').codes; | |
| 45 | 46 | const { | |
| 46 | 47 | validateString, | |
@@ -501,7 +502,6 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { | |||
| 501 | 502 | return this; | |
| 502 | 503 | }; | |
| 503 | 504 | ||
| 504 | - let warnInvalidPort = true; | ||
| 505 | 505 | function getHostname(self, rest, hostname, url) { | |
| 506 | 506 | for (let i = 0; i < hostname.length; ++i) { | |
| 507 | 507 | const code = hostname.charCodeAt(i); | |
@@ -513,12 +513,8 @@ function getHostname(self, rest, hostname, url) { | |||
| 513 | 513 | ||
| 514 | 514 | if (!isValid) { | |
| 515 | 515 | // If leftover starts with :, then it represents an invalid port. | |
| 516 | - // But url.parse() is lenient about it for now. | ||
| 517 | - // Issue a warning and continue. | ||
| 518 | - if (warnInvalidPort && code === CHAR_COLON) { | ||
| 519 | - const detail = `The URL ${url} is invalid. Future versions of Node.js will throw an error.`; | ||
| 520 | - process.emitWarning(detail, 'DeprecationWarning', 'DEP0170'); | ||
| 521 | - warnInvalidPort = false; | ||
| 516 | + if (code === CHAR_COLON) { | ||
| 517 | + throw new ERR_INVALID_ARG_VALUE('url', 'Invalid port in url', url); | ||
| 522 | 518 | } | |
| 523 | 519 | self.hostname = hostname.slice(0, i); | |
| 524 | 520 | return `/${hostname.slice(i)}${rest}`; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -862,22 +862,6 @@ const parseTests = { | |||
| 862 | 862 | href: 'http://a%22%20%3C\'b:b@cd/e?f' | |
| 863 | 863 | }, | |
| 864 | 864 | ||
| 865 | - // Git urls used by npm | ||
| 866 | - 'git+ssh://git@github.com:npm/npm': { | ||
| 867 | - protocol: 'git+ssh:', | ||
| 868 | - slashes: true, | ||
| 869 | - auth: 'git', | ||
| 870 | - host: 'github.com', | ||
| 871 | - port: null, | ||
| 872 | - hostname: 'github.com', | ||
| 873 | - hash: null, | ||
| 874 | - search: null, | ||
| 875 | - query: null, | ||
| 876 | - pathname: '/:npm/npm', | ||
| 877 | - path: '/:npm/npm', | ||
| 878 | - href: 'git+ssh://git@github.com/:npm/npm' | ||
| 879 | - }, | ||
| 880 | - | ||
| 881 | 865 | 'https://*': { | |
| 882 | 866 | protocol: 'https:', | |
| 883 | 867 | slashes: true, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,9 +83,7 @@ if (common.hasIntl) { | |||
| 83 | 83 | badURLs.forEach((badURL) => { | |
| 84 | 84 | common.spawnPromisified(process.execPath, ['-e', `url.parse(${JSON.stringify(badURL)})`]) | |
| 85 | 85 | .then(common.mustCall(({ code, stdout, stderr }) => { | |
| 86 | - assert.strictEqual(code, 0); | ||
| 87 | - assert.strictEqual(stdout, ''); | ||
| 88 | - assert.match(stderr, /\[DEP0170\] DeprecationWarning:/); | ||
| 86 | + assert.strictEqual(code, 1); | ||
| 89 | 87 | })); | |
| 90 | 88 | }); | |
| 91 | 89 | ||
@@ -94,10 +92,11 @@ if (common.hasIntl) { | |||
| 94 | 92 | DeprecationWarning: { | |
| 95 | 93 | // eslint-disable-next-line @stylistic/js/max-len | |
| 96 | 94 | DEP0169: '`url.parse()` behavior is not standardized and prone to errors that have security implications. Use the WHATWG URL API instead. CVEs are not issued for `url.parse()` vulnerabilities.', | |
| 97 | - DEP0170: `The URL ${badURLs[0]} is invalid. Future versions of Node.js will throw an error.`, | ||
| 98 | 95 | }, | |
| 99 | 96 | }); | |
| 100 | 97 | badURLs.forEach((badURL) => { | |
| 101 | - url.parse(badURL); | ||
| 98 | + assert.throws(() => url.parse(badURL), { | ||
| 99 | + code: 'ERR_INVALID_ARG_VALUE', | ||
| 100 | + }); | ||
| 102 | 101 | }); | |
| 103 | 102 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments