Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7fb1980

Browse filesBrowse files
anonrigdanielleadams
authored andcommitted
url: add pending-deprecation to url.parse()
PR-URL: #47203 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 9cbf897 commit 7fb1980
Copy full SHA for 7fb1980

File tree

Expand file treeCollapse file tree

2 files changed

+19
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/deprecations.md‎

Copy file name to clipboardExpand all lines: doc/api/deprecations.md
+4-1Lines changed: 4 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -3271,13 +3271,16 @@ Node-API callbacks.
32713271

32723272
<!-- YAML
32733273
changes:
3274+
- version: REPLACEME
3275+
pr-url: https://github.com/nodejs/node/pull/47203
3276+
description: Added support for `--pending-deprecation`.
32743277
- version:
32753278
- v18.13.0
32763279
pr-url: https://github.com/nodejs/node/pull/44919
32773280
description: Documentation-only deprecation.
32783281
-->
32793282

3280-
Type: Documentation-only
3283+
Type: Documentation-only (supports [`--pending-deprecation`][])
32813284

32823285
[`url.parse()`][] behavior is not standardized and prone to errors that
32833286
have security implications. Use the [WHATWG URL API][] instead. CVEs are not
Collapse file

‎lib/url.js‎

Copy file name to clipboardExpand all lines: lib/url.js
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ const {
6363
formatUrl,
6464
} = internalBinding('url');
6565

66+
const { getOptionValue } = require('internal/options');
67+
6668
// Original url.parse() API
6769

6870
function Url() {
@@ -147,7 +149,20 @@ const {
147149
CHAR_COLON,
148150
} = require('internal/constants');
149151

152+
let urlParseWarned = false;
153+
150154
function urlParse(url, parseQueryString, slashesDenoteHost) {
155+
if (!urlParseWarned && getOptionValue('--pending-deprecation')) {
156+
urlParseWarned = true;
157+
process.emitWarning(
158+
'`url.parse()` behavior is not standardized and prone to ' +
159+
'errors that have security implications. Use the WHATWG URL API ' +
160+
'instead. CVEs are not issued for `url.parse()` vulnerabilities.',
161+
'DeprecationWarning',
162+
'DEP0169',
163+
);
164+
}
165+
151166
if (url instanceof Url) return url;
152167

153168
const urlObject = new Url();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.