Skip to content

Commit b555ee1

Browse files
committed
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: nodejs#44911 (comment)
1 parent 6686d90 commit b555ee1

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

doc/api/deprecations.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -3258,7 +3258,7 @@ changes:
32583258
description: Runtime deprecation.
32593259
-->
32603260

3261-
Type: Runtime.
3261+
Type: Runtime
32623262

32633263
The implicit suppression of uncaught exceptions in Node-API callbacks is now
32643264
deprecated.
@@ -3267,6 +3267,21 @@ Set the flag [`--force-node-api-uncaught-exceptions-policy`][] to force Node.js
32673267
to emit an [`'uncaughtException'`][] event if the exception is not handled in
32683268
Node-API callbacks.
32693269

3270+
### DEP0169: Insecure url.parse()
3271+
3272+
<!-- YAML
3273+
changes:
3274+
- version:
3275+
- REPLACEME
3276+
pr-url: https://github.com/nodejs/node/pull/44918
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.
3284+
32703285
[Legacy URL API]: url.md#legacy-url-api
32713286
[NIST SP 800-38D]: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf
32723287
[RFC 6066]: https://tools.ietf.org/html/rfc6066#section-3

doc/api/url.md

+8-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:[email protected]: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:[email protected]: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/44918
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,8 @@ 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. Use the [WHATWG URL][] API
1569+
instead.
15751570

15761571
### `url.resolve(from, to)`
15771572

0 commit comments

Comments
 (0)