summaryrefslogtreecommitdiffstats
path: root/tests/check-qjson.c
diff options
context:
space:
mode:
authorMarkus Armbruster2018-08-23 18:39:52 +0200
committerMarkus Armbruster2018-08-24 20:26:37 +0200
commit4b1c0cd7c7f9f9cf2e46c0a9c9cd88b2cba3decd (patch)
tree5841258a3a8fd1fff3aeb2f70f3c68e308c68b8b /tests/check-qjson.c
parentjson: Leave rejecting invalid UTF-8 to parser (diff)
downloadqemu-4b1c0cd7c7f9f9cf2e46c0a9c9cd88b2cba3decd.tar.gz
qemu-4b1c0cd7c7f9f9cf2e46c0a9c9cd88b2cba3decd.tar.xz
qemu-4b1c0cd7c7f9f9cf2e46c0a9c9cd88b2cba3decd.zip
json: Accept overlong \xC0\x80 as U+0000 ("modified UTF-8")
Since the JSON grammer doesn't accept U+0000 anywhere, this merely exchanges one kind of parse error for another. It's purely for consistency with qobject_to_json(), which accepts \xC0\x80 (see commit e2ec3f97680). Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180823164025.12553-26-armbru@redhat.com>
Diffstat (limited to 'tests/check-qjson.c')
-rw-r--r--tests/check-qjson.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/tests/check-qjson.c b/tests/check-qjson.c
index 71c77d2f70..3abf12b4d2 100644
--- a/tests/check-qjson.c
+++ b/tests/check-qjson.c
@@ -152,12 +152,6 @@ static void string_with_quotes(void)
static void utf8_string(void)
{
/*
- * Problem: we can't easily deal with embedded U+0000. Parsing
- * the JSON string "this \\u0000" is fun" yields "this \0 is fun",
- * which gets misinterpreted as NUL-terminated "this ". We should
- * consider using overlong encoding \xC0\x80 for U+0000 ("modified
- * UTF-8").
- *
* Most test cases are scraped from Markus Kuhn's UTF-8 decoder
* capability and stress test at
* http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
@@ -586,7 +580,7 @@ static void utf8_string(void)
{
/* \U+0000 */
"\xC0\x80",
- NULL,
+ "\xC0\x80",
"\\u0000",
},
{