Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use non-symbols in isURLInstance check
- Loading branch information
1 parent
c4bd63b
commit e81593e
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
patches/node/lib_use_non-symbols_in_isurlinstance_check.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Shelley Vohr <shelley.vohr@gmail.com> | ||
Date: Tue, 4 Aug 2020 09:17:06 -0700 | ||
Subject: lib: use non-symbols in isURLInstance check | ||
|
||
This slightly changes the conditional used to determine whether or | ||
not something is a URL instance. Since Node.js adds symbols to the URL | ||
not specified by the WHATWG, those symbols are not present in other | ||
implementations (like Blink's) and therefore can cause false negatives. | ||
|
||
This fixes that by slightly changing the check to properties present | ||
in all URL instances as specified in the WHATWG spec. | ||
|
||
Upstreamed at: https://github.com/nodejs/node/pull/34622. | ||
|
||
diff --git a/lib/internal/url.js b/lib/internal/url.js | ||
index 09fa9f2cf47d50d369fa3eae378f81767486e83e..e6a37dcd22c51b37838a577be44be198649eabad 100644 | ||
--- a/lib/internal/url.js | ||
+++ b/lib/internal/url.js | ||
@@ -1348,8 +1348,7 @@ function getPathFromURLPosix(url) { | ||
function fileURLToPath(path) { | ||
if (typeof path === 'string') | ||
path = new URL(path); | ||
- else if (path == null || !path[searchParams] || | ||
- !path[searchParams][searchParams]) | ||
+ else if (path == null || !path['origin'] || !path['href']) | ||
throw new ERR_INVALID_ARG_TYPE('path', ['string', 'URL'], path); | ||
if (path.protocol !== 'file:') | ||
throw new ERR_INVALID_URL_SCHEME('file'); | ||
@@ -1397,8 +1396,7 @@ function pathToFileURL(filepath) { | ||
} | ||
|
||
function toPathIfFileURL(fileURLOrPath) { | ||
- if (fileURLOrPath == null || !fileURLOrPath[searchParams] || | ||
- !fileURLOrPath[searchParams][searchParams]) | ||
+ if (fileURLOrPath == null || !fileURLOrPath['origin'] || !fileURLOrPath['href']) | ||
return fileURLOrPath; | ||
return fileURLToPath(fileURLOrPath); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters