From 3a1d8accd493137606f42293896effa114d8d663 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 4 Aug 2020 09:18:43 -0700 Subject: [PATCH] fix: use non-symbols in isURLInstance check --- patches/node/.patches | 3 ++ ...e_non-symbols_in_isurlinstance_check.patch | 30 +++++++++++++++++++ spec/node-spec.js | 9 ++++++ 3 files changed, 42 insertions(+) create mode 100644 patches/node/lib_use_non-symbols_in_isurlinstance_check.patch diff --git a/patches/node/.patches b/patches/node/.patches index 70ce8c1dd15c1..c683a16fa1428 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -51,3 +51,6 @@ crypto_update_root_certificates_to_nss_3_47.patch tools_update_certdata_txt_to_nss_3_53.patch crypto_update_root_certificates_to_nss_3_53.patch darwin_work_around_clock_jumping_back_in_time.patch +fix_do_not_register_the_esm_loader_in_renderer_processes.patch +fix_allow_preventing_setpromiserejectcallback.patch +lib_use_non-symbols_in_isurlinstance_check.patch diff --git a/patches/node/lib_use_non-symbols_in_isurlinstance_check.patch b/patches/node/lib_use_non-symbols_in_isurlinstance_check.patch new file mode 100644 index 0000000000000..61862987fe3e6 --- /dev/null +++ b/patches/node/lib_use_non-symbols_in_isurlinstance_check.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shelley Vohr +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 78f5b32745a0436337233e8a4b57b89263effad6..ace274501f2c1f6bb06f600abb850e737c988338 100644 +--- a/lib/internal/url.js ++++ b/lib/internal/url.js +@@ -1394,8 +1394,8 @@ function pathToFileURL(filepath) { + } + + function isURLInstance(fileURLOrPath) { +- return fileURLOrPath != null && fileURLOrPath[searchParams] && +- fileURLOrPath[searchParams][searchParams]; ++ return fileURLOrPath != null && fileURLOrPath['href'] && ++ fileURLOrPath['origin']; + } + + function toPathIfFileURL(fileURLOrPath) { diff --git a/spec/node-spec.js b/spec/node-spec.js index ab9e180d31238..75516b449ef85 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -191,6 +191,15 @@ describe('node feature', () => { }); }); + describe('URL handling in the renderer process', () => { + it('can successfully handle WHATWG URLs constructed by Blink', () => { + const url = new URL('file://' + path.resolve(fixtures, 'pages', 'base-page.html')); + expect(() => { + fs.createReadStream(url); + }).to.not.throw(); + }); + }); + describe('error thrown in main process node context', () => { it('gets emitted as a process uncaughtException event', () => { const error = ipcRenderer.sendSync('handle-uncaught-exception', 'hello');