Commit Graph

9 Commits

Author SHA1 Message Date
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
xackus
d1202b1f66 fix overflow in parseFloat 2020-03-29 11:50:41 +02:00
Benjamin Feng
a81ae1223d Convert a lot of json tests to use testing.allocator 2020-02-12 17:17:56 -06:00
hryx
2933a8241a json: disallow overlong and out-of-range UTF-8
Fixes #2379

= Overlong (non-shortest) sequences

UTF-8's unique encoding scheme allows for some Unicode codepoints
to be represented in multiple ways. For any of these characters,
the spec forbids all but the shortest form. These disallowed longer
sequences are called "overlong". As an interesting side effect of
this rule, the bytes C0 and C1 never appear in valid UTF-8.

= Codepoint range

UTF-8 disallows representation of codepoints beyond U+10FFFF,
which is the highest character which can be encoded in UTF-16.
Because a 4-byte sequence is capable of resulting in such characters,
they must be explicitly rejected. This rule also has an interesting
side effect, which is that bytes F5 to FF never appear.

= References

Detecting an overlong version of a codepoint could get gnarly, but
luckily The Unicode Consortium did the hard work by creating this
handy table of valid byte sequences:

https://unicode.org/versions/corrigendum1.html

I thought this mapped nicely to the parser's state machine, so I
rearranged the relevant states to make use of it.
2020-01-07 12:07:44 -05:00
Andrew Kelley
53913acaf7
zig fmt and update extern fn to callconv(.C) 2020-01-06 15:34:50 -05:00
xackus
6d3b95a708 Stricter tests for non-streaming parser 2019-11-11 23:41:53 +01:00
xackus
f9b7d6d75d Fix bugs in JSON parser
Make comments into documentation where appropriate
2019-11-11 23:25:54 +01:00
xackus
371747d8fb json: surrogate pair support
test json.Parser with tests used for json.Streaming parser
(some don't pass yet)
2019-11-11 22:06:00 +01:00
Andrew Kelley
ed36dbbd9c
mv std/ lib/
that's all this commit does. further commits will fix cli flags and
such.

see #2221
2019-09-25 23:35:41 -04:00