Skip to content

Commit b4cc30e

Browse files
Trottdanielleadams
authored andcommitted
doc: deprecate url.parse()
This is a documentation-deprecation only and it is possible that it will not proceed to a runtime-deprecation any time in the foreseeable future. But url.parse() is not standardized and prone to errors that have security implications. Refs: #44911 (comment) PR-URL: #44919 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Danielle Adams <adamzdanielle@gmail.com>
1 parent 4fcbc92 commit b4cc30e

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

doc/api/deprecations.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -2288,6 +2288,9 @@ future release.
22882288

22892289
<!-- YAML
22902290
changes:
2291+
- version: REPLACEME
2292+
pr-url: https://github.com/nodejs/node/pull/44919
2293+
description: \`url.parse()` is deprecated again in DEP0169.
22912294
- version:
22922295
- v15.13.0
22932296
- v14.17.0
@@ -2300,7 +2303,7 @@ changes:
23002303

23012304
Type: Deprecation revoked
23022305

2303-
The [Legacy URL API][] is deprecated. This includes [`url.format()`][],
2306+
The [legacy URL API][] is deprecated. This includes [`url.format()`][],
23042307
[`url.parse()`][], [`url.resolve()`][], and the [legacy `urlObject`][]. Please
23052308
use the [WHATWG URL API][] instead.
23062309

@@ -3255,7 +3258,7 @@ changes:
32553258
description: Runtime deprecation.
32563259
-->
32573260

3258-
Type: Runtime.
3261+
Type: Runtime
32593262

32603263
The implicit suppression of uncaught exceptions in Node-API callbacks is now
32613264
deprecated.
@@ -3264,7 +3267,22 @@ Set the flag [`--force-node-api-uncaught-exceptions-policy`][] to force Node.js
32643267
to emit an [`'uncaughtException'`][] event if the exception is not handled in
32653268
Node-API callbacks.
32663269

3267-
[Legacy URL API]: url.md#legacy-url-api
3270+
### DEP0169: Insecure url.parse()
3271+
3272+
<!-- YAML
3273+
changes:
3274+
- version:
3275+
- REPLACEME
3276+
pr-url: https://github.com/nodejs/node/pull/44919
3277+
description: Documentation-only deprecation.
3278+
-->
3279+
3280+
Type: Documentation-only
3281+
3282+
[`url.parse()`][] behavior is not standardized and prone to errors that
3283+
have security implications. Use the [WHATWG URL API][] instead. CVEs are not
3284+
issued for `url.parse()` vulnerabilities.
3285+
32683286
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
32693287
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3
32703288
[RFC 8247 Section 2.4]: https://www.rfc-editor.org/rfc/rfc8247#section-2.4
@@ -3410,6 +3428,7 @@ Node-API callbacks.
34103428
[alloc_unsafe_size]: buffer.md#static-method-bufferallocunsafesize
34113429
[from_arraybuffer]: buffer.md#static-method-bufferfromarraybuffer-byteoffset-length
34123430
[from_string_encoding]: buffer.md#static-method-bufferfromstring-encoding
3431+
[legacy URL API]: url.md#legacy-url-api
34133432
[legacy `urlObject`]: url.md#legacy-urlobject
34143433
[static methods of `crypto.Certificate()`]: crypto.md#class-certificate
34153434
[subpath exports]: packages.md#subpath-exports

doc/api/url.md

+9-13
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The `node:url` module provides two APIs for working with URLs: a legacy API that
2727
is Node.js specific, and a newer API that implements the same
2828
[WHATWG URL Standard][] used by web browsers.
2929

30-
A comparison between the WHATWG and Legacy APIs is provided below. Above the URL
30+
A comparison between the WHATWG and legacy APIs is provided below. Above the URL
3131
`'https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash'`, properties
3232
of an object returned by the legacy `url.parse()` are shown. Below it are
3333
properties of a WHATWG `URL` object.
@@ -63,7 +63,7 @@ const myURL =
6363
new URL('https://user:pass@sub.example.com:8080/p/a/t/h?query=string#hash');
6464
```
6565

66-
Parsing the URL string using the Legacy API:
66+
Parsing the URL string using the legacy API:
6767

6868
```mjs
6969
import url from 'node:url';
@@ -1521,6 +1521,9 @@ The formatting process operates as follows:
15211521
<!-- YAML
15221522
added: v0.1.25
15231523
changes:
1524+
- version: REPLACEME
1525+
pr-url: https://github.com/nodejs/node/pull/44919
1526+
description: Documentation-only deprecation.
15241527
- version:
15251528
- v15.13.0
15261529
- v14.17.0
@@ -1540,7 +1543,7 @@ changes:
15401543
when no query string is present.
15411544
-->
15421545
1543-
> Stability: 3 - Legacy: Use the WHATWG URL API instead.
1546+
> Stability: 0 - Deprecated: Use the WHATWG URL API instead.
15441547
15451548
* `urlString` {string} The URL string to parse.
15461549
* `parseQueryString` {boolean} If `true`, the `query` property will always
@@ -1562,16 +1565,9 @@ A `URIError` is thrown if the `auth` property is present but cannot be decoded.
15621565

15631566
`url.parse()` uses a lenient, non-standard algorithm for parsing URL
15641567
strings. It is prone to security issues such as [host name spoofing][]
1565-
and incorrect handling of usernames and passwords.
1566-
1567-
`url.parse()` is an exception to most of the legacy APIs. Despite its security
1568-
concerns, it is legacy and not deprecated because it is:
1569-
1570-
* Faster than the alternative WHATWG `URL` parser.
1571-
* Easier to use with regards to relative URLs than the alternative WHATWG `URL` API.
1572-
* Widely relied upon within the npm ecosystem.
1573-
1574-
Use with caution.
1568+
and incorrect handling of usernames and passwords. Do not use with untrusted
1569+
input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
1570+
[WHATWG URL][] API instead.
15751571

15761572
### `url.resolve(from, to)`
15771573

0 commit comments

Comments
 (0)