summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-06-08 21:53:36 +0100
committerAndreas Kling <kling@serenityos.org>2021-06-08 23:53:13 +0200
commit83be39c91aeff53c5dfd158844e8ad73f10ae9d2 (patch)
treea7b493153ec3319a886a493a962d6541ae6a4ff9 /Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
parent9b35231453ddcf939dd10c40787ee7e5ef5b5fe0 (diff)
downloadserenity-83be39c91aeff53c5dfd158844e8ad73f10ae9d2.zip
LibJS: Handle Proxy with Array target in IsArray() abstract operation
This was missing from Value::is_array(), which is equivalent to the spec's IsArray() abstract operation - it treats a Proxy value with an Array target object as being an Array. It can throw, so needs both the global object and an exception check now.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/StringConstructor.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringConstructor.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
index 30746e16e4..f27a47be6f 100644
--- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp
@@ -72,7 +72,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw)
vm.throw_exception<TypeError>(global_object, ErrorType::StringRawCannotConvert, raw.is_null() ? "null" : "undefined");
return {};
}
- if (!raw.is_array())
+ // FIXME: This should use length_of_array_like() and work with any object
+ if (!raw.is_object() || !raw.as_object().is_array())
return js_string(vm, "");
auto* array = static_cast<Array*>(raw.to_object(global_object));