mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
lib: mark URL/URLSearchParams as uncloneable and untransferable
Mark URL/URLSearchParams as uncloneable and untransferable to reject them in `structuredClone` and `port.postMessage`. PR-URL: https://github.com/nodejs/node/pull/47497 Refs: https://github.com/nodejs/node/pull/47214 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
parent
5da84a6341
commit
c5b0b894ed
@ -47,6 +47,10 @@ const {
|
||||
SideEffectFreeRegExpPrototypeSymbolReplace,
|
||||
} = require('internal/util');
|
||||
|
||||
const {
|
||||
markTransferMode,
|
||||
} = require('internal/worker/js_transferable');
|
||||
|
||||
const {
|
||||
codes: {
|
||||
ERR_ARG_NOT_ITERABLE,
|
||||
@ -326,6 +330,8 @@ class URLSearchParams {
|
||||
// Default parameter is necessary to keep URLSearchParams.length === 0 in
|
||||
// accordance with Web IDL spec.
|
||||
constructor(init = undefined) {
|
||||
markTransferMode(this, false, false);
|
||||
|
||||
if (init == null) {
|
||||
// Do nothing
|
||||
} else if (typeof init === 'object' || typeof init === 'function') {
|
||||
@ -761,6 +767,8 @@ class URL {
|
||||
#searchParams;
|
||||
|
||||
constructor(input, base = undefined) {
|
||||
markTransferMode(this, false, false);
|
||||
|
||||
if (arguments.length === 0) {
|
||||
throw new ERR_MISSING_ARGS('url');
|
||||
}
|
||||
|
@ -6,9 +6,7 @@
|
||||
"fail": {
|
||||
"note": "We are faking location with a URL object for the sake of the testharness and it has searchParams.",
|
||||
"expected": [
|
||||
"searchParams on location object",
|
||||
"URL: no structured serialize/deserialize support",
|
||||
"URLSearchParams: no structured serialize/deserialize support"
|
||||
"searchParams on location object"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user