json_parse(): Disallow control characters in strings by default
Deviating from the standard, but more consistent other FU functions.
This commit is contained in:
parent
a43dc70ff9
commit
55baa6c9a6
3 changed files with 28 additions and 10 deletions
|
|
@ -24,6 +24,11 @@ my @error = (
|
|||
'"\udc12\u1234"',
|
||||
"\"\x{110000}\"",
|
||||
|
||||
'"\u0000"',
|
||||
'"\b"',
|
||||
'"\f"',
|
||||
'"\u007f"',
|
||||
|
||||
'1.',
|
||||
'01',
|
||||
'1e',
|
||||
|
|
@ -82,9 +87,9 @@ sub str($in, $exp) {
|
|||
}
|
||||
str '""', '';
|
||||
str '"hello, world"', 'hello, world';
|
||||
str '"\u0000\u0099\u0234\u1234"', "\x{00}\x{99}\x{234}\x{1234}";
|
||||
str "\"\x{7f}\x{99}\x{234}\x{1234}\x{12345}\"", "\x{7f}\x{99}\x{234}\x{1234}\x{12345}";
|
||||
str '"\/\"\\\\\b\t\n\f\r"', "/\"\\\x{08}\x{09}\x{0a}\x{0c}\x{0d}";
|
||||
str '"\u0099\u0234\u1234"', "\x{99}\x{234}\x{1234}";
|
||||
str "\"\x{99}\x{234}\x{1234}\x{12345}\"", "\x{99}\x{234}\x{1234}\x{12345}";
|
||||
str '"\/\"\\\\\t\n\r"', "/\"\\\x{09}\x{0a}\x{0d}";
|
||||
str '"\uD83D\uDE03"', "\x{1F603}";
|
||||
|
||||
sub num($in, $exp=$in) {
|
||||
|
|
@ -186,6 +191,7 @@ for (2000..2100, 4000..4200, 8100..8200, 12200..12300, 16300..16400) {
|
|||
ok !eval { json_parse '[[[[]]]]', max_depth => 4; 1 };
|
||||
ok !eval { json_parse '{"":{"":{"":{"":1}}}}', max_depth => 4; 1 };
|
||||
|
||||
is json_parse('"\u0000\b\f\u007f"', allow_control => 1), "\x00\x08\x0c\x7f";
|
||||
|
||||
# 500 depth
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue