From 969aee2022cf59f014381032104ce343ede33c34 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 22 Aug 2021 21:20:00 +0100 Subject: LibJS: Add missing builtin calendar check to ParseTemporalCalendarString See: https://github.com/tc39/proposal-temporal/commit/48b11d6 --- .../LibJS/Runtime/Temporal/AbstractOperations.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index cf347132b1..0da9c1c056 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -510,8 +511,10 @@ Optional parse_temporal_instant_string(GlobalObject& global_obj } // 13.37 ParseTemporalCalendarString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporalcalendarstring -Optional parse_temporal_calendar_string([[maybe_unused]] GlobalObject& global_object, [[maybe_unused]] String const& iso_string) +Optional parse_temporal_calendar_string(GlobalObject& global_object, [[maybe_unused]] String const& iso_string) { + auto& vm = global_object.vm(); + // 1. Assert: Type(isoString) is String. // 2. If isoString does not satisfy the syntax of a TemporalCalendarString (see 13.33), then @@ -526,7 +529,14 @@ Optional parse_temporal_calendar_string([[maybe_unused]] GlobalObject& g return "iso8601"; } - // 5. Return id. + // 5. If ! IsBuiltinCalendar(id) is false, then + if (!is_builtin_calendar(*id_part)) { + // a. Throw a RangeError exception. + vm.throw_exception(global_object, ErrorType::TemporalInvalidCalendarIdentifier, *id_part); + return {}; + } + + // 6. Return id. return id_part.value(); } -- cgit v1.2.3