mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +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: https://github.com/LadybirdBrowser/ladybird/commit/660d533b501 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;
|
||||
|
||||
auto descriptor = TRY(object_to_check->internal_get_own_property(property_key));
|
||||
if (!descriptor.has_value())
|
||||
continue;
|
||||
if (!*descriptor->enumerable)
|
||||
non_enumerable_properties.set(move(property_key));
|
||||
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
Reference in a new issue