From 3eb77a700434ed6d9b51e326fa4d49c530fcd473 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 20 May 2022 09:57:30 -0400 Subject: JSON: detect duplicate dictionary keys while parsing --- libtests/libtests.testcov | 1 + libtests/qtest/json_parse.test | 1 + libtests/qtest/json_parse/bad-40.json | 6 ++++++ libtests/qtest/json_parse/bad-40.out | 1 + 4 files changed, 9 insertions(+) create mode 100644 libtests/qtest/json_parse/bad-40.json create mode 100644 libtests/qtest/json_parse/bad-40.out (limited to 'libtests') diff --git a/libtests/libtests.testcov b/libtests/libtests.testcov index 1f006e81..21def9f3 100644 --- a/libtests/libtests.testcov +++ b/libtests/libtests.testcov @@ -92,3 +92,4 @@ JSON optional key 0 JSON 16 high high 0 JSON 16 low not after high 0 JSON 16 dangling high 0 +JSON parse duplicate key 0 diff --git a/libtests/qtest/json_parse.test b/libtests/qtest/json_parse.test index 6d57e92c..112da0a9 100644 --- a/libtests/qtest/json_parse.test +++ b/libtests/qtest/json_parse.test @@ -120,6 +120,7 @@ my @bad = ( "stray low surrogate", # 37 "high high surrogate", # 38 "dangling high surrogate", # 39 + "duplicate dictionary key", # 40 ); my $i = 0; diff --git a/libtests/qtest/json_parse/bad-40.json b/libtests/qtest/json_parse/bad-40.json new file mode 100644 index 00000000..f60bcc11 --- /dev/null +++ b/libtests/qtest/json_parse/bad-40.json @@ -0,0 +1,6 @@ +{ + "one": 1, + "two": 2, + "one": 3, + "four": 4 +} diff --git a/libtests/qtest/json_parse/bad-40.out b/libtests/qtest/json_parse/bad-40.out new file mode 100644 index 00000000..28a78bfb --- /dev/null +++ b/libtests/qtest/json_parse/bad-40.out @@ -0,0 +1 @@ +exception: bad-40.json: JSON: offset 28: duplicated dictionary key -- cgit v1.2.3-54-g00ecf