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 461ef04

Browse filesBrowse files
anonrigRafaelGSS
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 3e7f8e8 commit 461ef04
Copy full SHA for 461ef04

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
@@ -3280,13 +3280,16 @@ Node-API callbacks.
32803280

32813281
<!-- YAML
32823282
changes:
3283+
- version: REPLACEME
3284+
pr-url: https://github.com/nodejs/node/pull/47203
3285+
description: Added support for `--pending-deprecation`.
32833286
- version:
32843287
- v19.0.0
32853288
pr-url: https://github.com/nodejs/node/pull/44919
32863289
description: Documentation-only deprecation.
32873290
-->
32883291

3289-
Type: Documentation-only
3292+
Type: Documentation-only (supports [`--pending-deprecation`][])
32903293

32913294
[`url.parse()`][] behavior is not standardized and prone to errors that
32923295
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
@@ -62,6 +62,8 @@ const {
6262
formatUrl,
6363
} = internalBinding('url');
6464

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

6769
function Url() {
@@ -146,7 +148,20 @@ const {
146148
CHAR_COLON,
147149
} = require('internal/constants');
148150

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

152167
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.