mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
LibJS: Disallow large dates in ToTemporalMonthDay
This is a normative change in the Temporal proposal. See:
bd5ac12
Note: No test added here because this only affects non-ISO-8601
calendars, which we do not yet support.
This commit is contained in:
parent
080d32c7d0
commit
29c8e7c203
Notes:
github-actions[bot]
2025-03-01 13:50:12 +00:00
Author: https://github.com/trflynn89
Commit: 29c8e7c203
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3734
1 changed files with 13 additions and 12 deletions
|
@ -88,33 +88,34 @@ ThrowCompletionOr<GC::Ref<PlainMonthDay>> to_temporal_month_day(VM& vm, Value it
|
|||
// 9. Perform ? GetTemporalOverflowOption(resolvedOptions).
|
||||
TRY(get_temporal_overflow_option(vm, resolved_options));
|
||||
|
||||
// 10. If result.[[Year]] is empty, then
|
||||
if (!parse_result.year.has_value()) {
|
||||
// a. Assert: calendar is "iso8601".
|
||||
VERIFY(calendar == "iso8601"sv);
|
||||
|
||||
// b. Let referenceISOYear be 1972 (the first ISO 8601 leap year after the epoch).
|
||||
// 10. If calendar is "iso8601", then
|
||||
if (calendar == "iso8601"sv) {
|
||||
// a. Let referenceISOYear be 1972 (the first ISO 8601 leap year after the epoch).
|
||||
static constexpr i32 reference_iso_year = 1972;
|
||||
|
||||
// c. Let isoDate be CreateISODateRecord(referenceISOYear, result.[[Month]], result.[[Day]]).
|
||||
// b. Let isoDate be CreateISODateRecord(referenceISOYear, result.[[Month]], result.[[Day]]).
|
||||
auto iso_date = create_iso_date_record(reference_iso_year, parse_result.month, parse_result.day);
|
||||
|
||||
// d. Return ! CreateTemporalMonthDay(isoDate, calendar).
|
||||
// c. Return ! CreateTemporalMonthDay(isoDate, calendar).
|
||||
return MUST(create_temporal_month_day(vm, iso_date, move(calendar)));
|
||||
}
|
||||
|
||||
// 11. Let isoDate be CreateISODateRecord(result.[[Year]], result.[[Month]], result.[[Day]]).
|
||||
auto iso_date = create_iso_date_record(*parse_result.year, parse_result.month, parse_result.day);
|
||||
|
||||
// 12. Set result to ISODateToFields(calendar, isoDate, MONTH-DAY).
|
||||
// 12. If ISODateWithinLimits(isoDate) is false, throw a RangeError exception.
|
||||
if (!iso_date_within_limits(iso_date))
|
||||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidPlainMonthDay);
|
||||
|
||||
// 13. Set result to ISODateToFields(calendar, isoDate, MONTH-DAY).
|
||||
auto result = iso_date_to_fields(calendar, iso_date, DateType::MonthDay);
|
||||
|
||||
// 13. NOTE: The following operation is called with CONSTRAIN regardless of the value of overflow, in order for the
|
||||
// 14. NOTE: The following operation is called with CONSTRAIN regardless of the value of overflow, in order for the
|
||||
// calendar to store a canonical value in the [[Year]] field of the [[ISODate]] internal slot of the result.
|
||||
// 14. Set isoDate to ? CalendarMonthDayFromFields(calendar, result, CONSTRAIN).
|
||||
// 15. Set isoDate to ? CalendarMonthDayFromFields(calendar, result, CONSTRAIN).
|
||||
iso_date = TRY(calendar_month_day_from_fields(vm, calendar, result, Overflow::Constrain));
|
||||
|
||||
// 15. Return ! CreateTemporalMonthDay(isoDate, calendar).
|
||||
// 16. Return ! CreateTemporalMonthDay(isoDate, calendar).
|
||||
return MUST(create_temporal_month_day(vm, iso_date, move(calendar)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue