mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
url: validate href setter receiver first
Validate the URL receiver before converting the assigned href value. Fixes: https://github.com/nodejs/node/issues/67344 Signed-off-by: dansatch <dansatch98@gmail.com> PR-URL: https://github.com/nodejs/node/pull/67350 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
edf06a260a
commit
c8ee016027
2 files changed
+18
-1
No files matched your search
+2
-1
@@ -1022,8 +1022,9 @@ class URL {
|
||||
}
|
||||
|
||||
set href(value) {
|
||||
const context = this.#context;
|
||||
value = `${value}`;
|
||||
const href = bindingUrl.update(this.#context.href, updateActions.kHref, value);
|
||||
const href = bindingUrl.update(context.href, updateActions.kHref, value);
|
||||
if (!href) { throw new ERR_INVALID_URL(value); }
|
||||
this.#updateContext(href, true);
|
||||
}
|
||||
|
||||
@@ -13,3 +13,19 @@ assert.throws(() => {
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(url, ref);
|
||||
|
||||
const setHref = Object.getOwnPropertyDescriptor(URL.prototype, 'href').set;
|
||||
let calls = 0;
|
||||
|
||||
assert.throws(() => {
|
||||
setHref.call({}, {
|
||||
toString() {
|
||||
calls++;
|
||||
return 'https://example.com/';
|
||||
},
|
||||
});
|
||||
}, {
|
||||
name: 'TypeError',
|
||||
});
|
||||
|
||||
assert.strictEqual(calls, 0);
|
||||
Reference in new issue
Block a user