Commit graph

6 commits

Author SHA1 Message Date
Andreas Kling
7025dd1fa7 Libraries: Parse JS strings from UTF-16
Thread UTF-16 string input through JSON, script parsing, Date parsing,
Intl option parsing, Temporal parsing, and the helper library boundaries
that feed those parsers. Preserve ASCII fast paths where the source data
is known to be ASCII.
2026-06-22 19:51:25 +02:00
Timothy Flynn
edaed9adfa LibJS: Protect DateParser from non-ASCII input
DateParser is a GenericLexer, which is not particularly UTF-8 aware.
Other engines do not accept ASCII input, so let's just reject non-ASCII
strings outright.

While we are here, let's avoid the std ctype header. It is explicitly
undefined behavior to provide code points to isspace, isalpha, etc. that
do not fit in an unsigned char. Although this isn't reachable any longer
let's just nip it in the bud and use our safe AK character types.

Just to demonstrate, the following returns different values for me on
different systems and with different compilers:

    isdigit(0xff01)
    isalpha(0xff01)
    isspace(0xff01)
2026-05-22 17:30:36 +02:00
Timothy Flynn
3dcbb4bbb0 LibJS: Avoid use of std:: in DateParser
* Replace std::pair with a named struct, which we've always preferred.
* Remove needless use of std::ignore.
* Use concepts from AK instead of type traits from the STL.
2026-05-22 17:30:36 +02:00
Timothy Flynn
1cfa6965bc LibJS: Organize DateParser a bit
This class was effectively upside-down compared to the way we typically
organize our classes.

* Put public section above private section
* Put methods above members
* Add newlines between methods
2026-05-22 17:30:36 +02:00
Andreas Kling
84029461f8 LibJS: Tighten ISO-like Date parsing edge cases
Accept single-digit minute and second components for space-separated
ISO-like dates. This matches other engines and the SpiderMonkey test.

Keep T-separated date-times stricter by rejecting bare hour offsets like
-07, while still allowing the non-standard space-separated form.
2026-05-22 01:56:57 +02:00
Manuel Zahariev
8263e7fa51 LibJS: DateParser for simplified ISO8601 and non-standard date strings 2025-05-26 18:48:09 +02:00