Skip to content

Commit fec80ce

Browse files
catamorphismjustinmichaud
authored andcommitted
[JSC] Refactor Temporal calendar annotation key parsing
https://bugs.webkit.org/show_bug.cgi?id=223166 Reviewed by Justin Michaud and Sosuke Suzuki. This does not change anything currently, but is groundwork for implementing a normative change to the Temporal proposal: tc39/proposal-temporal#2397 It changes parseCalendar() to handle unknown annotation keys and known annotation keys with the `!` critical flag. (Although those are still disallowed by canBeCalendar() at this time, I will send a follow-up PR for that.) Note this code was already submitted as part of #36361 which I'm trying to split up into smaller, more easily reviewable parts. * Source/JavaScriptCore/runtime/ISO8601.cpp: (JSC::ISO8601::parseCalendar): Canonical link: https://commits.webkit.org/293522@main
1 parent e6cbba0 commit fec80ce

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

Source/JavaScriptCore/runtime/ISO8601.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,23 @@ static std::optional<CalendarRecord> parseCalendar(StringParsingBuffer<Character
779779

780780
if (!canBeCalendar(buffer))
781781
return std::nullopt;
782-
buffer.advanceBy(6);
782+
// Skip '['
783+
buffer.advance();
784+
785+
// Parse the key
786+
unsigned keyLength = 0;
787+
while (buffer[keyLength] != '=')
788+
keyLength++;
789+
if (!keyLength)
790+
return std::nullopt;
791+
buffer.advanceBy(keyLength);
783792

784793
if (buffer.atEnd())
785794
return std::nullopt;
786795

796+
// Consume the '='
797+
buffer.advance();
798+
787799
unsigned nameLength = 0;
788800
{
789801
unsigned index = 0;

0 commit comments

Comments
 (0)