Skip to content

Conversation

@chqrlie
Copy link
Collaborator

@chqrlie chqrlie commented Mar 27, 2024

  • reject AM/PM suffix for hours > 12
  • stricter time parser (fixes last v8 test)

- reject AM/PM suffix for hours > 12
- stricter time parser (fixes last v8 test)
} else
if (has_time && string_match(sp, &p, "PM")) {
if (fields[3] < 12)
if (fields[3] != 12)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also have a range check?

Suggested change
if (fields[3] != 12)
if (fields[3] > 12)
return FALSE;
if (fields[3] != 12)

It looks like it'd accept e.g. 13:00 PM now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test fields[3] != 12 suffices to reject hours larger than 12 because they will be incremented and exceed 24, thus be caught by the range check in js_Date_parse().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I shall add an explanatory comment for clarity

@chqrlie chqrlie merged commit 93d1742 into quickjs-ng:master Mar 27, 2024
@chqrlie chqrlie deleted the date-parse-fix branch March 27, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants