mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 01:00:05 +00:00
LibJS: Don't assume [[GetOwnPropertyDescriptor]] always succeeds
It can fail if we're talking to a badly-behaved proxy when enumerating object properties for iteration.
This commit is contained in:
parent
37c7eb14fe
commit
660d533b50
Notes:
github-actions[bot]
2025-03-20 17:52:44 +00:00
Author: https://github.com/awesomekling
Commit: 660d533b50
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4017
2 changed files with 14 additions and 0 deletions
|
@ -1732,6 +1732,8 @@ inline ThrowCompletionOr<Object*> get_object_property_iterator(VM& vm, Value val
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto descriptor = TRY(object_to_check->internal_get_own_property(property_key));
|
auto descriptor = TRY(object_to_check->internal_get_own_property(property_key));
|
||||||
|
if (!descriptor.has_value())
|
||||||
|
continue;
|
||||||
if (!*descriptor->enumerable)
|
if (!*descriptor->enumerable)
|
||||||
non_enumerable_properties.set(move(property_key));
|
non_enumerable_properties.set(move(property_key));
|
||||||
else
|
else
|
||||||
|
|
12
Libraries/LibJS/Tests/builtins/Proxy/iterate-over-proxy.js
Normal file
12
Libraries/LibJS/Tests/builtins/Proxy/iterate-over-proxy.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
test("iterate over bogus proxy", () => {
|
||||||
|
expect(() => {
|
||||||
|
let proxy = new Proxy([123], {
|
||||||
|
getOwnPropertyDescriptor: function (p) {
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const p in proxy) {
|
||||||
|
}
|
||||||
|
}).toThrow();
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue