From 33eac1c7cffa967f253220c04dbfb042fb56514e Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 11 May 2026 11:41:19 +0100 Subject: [PATCH] LibJS: Skip numeric index parse for non-numeric property keys --- Libraries/LibJS/Runtime/PropertyKey.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Runtime/PropertyKey.h b/Libraries/LibJS/Runtime/PropertyKey.h index 7e7443f49f..38b74617be 100644 --- a/Libraries/LibJS/Runtime/PropertyKey.h +++ b/Libraries/LibJS/Runtime/PropertyKey.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -75,8 +76,9 @@ public: PropertyKey(Utf16FlyString string, StringMayBeNumber string_may_be_number = StringMayBeNumber::Yes) { - if (string_may_be_number == StringMayBeNumber::Yes) { - if (!string.is_empty() && !(string.code_unit_at(0) == '0' && string.length_in_code_units() > 1)) { + if (string_may_be_number == StringMayBeNumber::Yes && !string.is_empty()) { + auto first_code_unit = string.code_unit_at(0); + if (is_ascii_digit(first_code_unit) && !(first_code_unit == '0' && string.length_in_code_units() > 1)) { auto property_index = string.to_number(TrimWhitespace::No); if (property_index.has_value() && property_index.value() < NumericLimits::max()) { m_number = static_cast(property_index.release_value()) << 2 | NUMBER_FLAG;