From 821484f170000e68114285b538c563be9858d119 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 29 Dec 2019 22:18:45 +0100 Subject: AK: Fix JSON parser crashing when encountering UTF-8 The mechanism that caches the most recently seen string for each first character was indexing into the cache using a 'char' subscript. Oops! --- AK/Tests/TestJSON.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'AK/Tests') diff --git a/AK/Tests/TestJSON.cpp b/AK/Tests/TestJSON.cpp index bbdfd25817..e532040c4d 100644 --- a/AK/Tests/TestJSON.cpp +++ b/AK/Tests/TestJSON.cpp @@ -74,4 +74,12 @@ TEST_CASE(json_empty_string) EXPECT_EQ(json.as_string().is_empty(), true); } +TEST_CASE(json_utf8_character) +{ + auto json = JsonValue::from_string("\"\xc3\x84\""); + EXPECT_EQ(json.type(), JsonValue::Type::String); + EXPECT_EQ(json.as_string().is_null(), false); + EXPECT_EQ(json.as_string().length(), 2); +} + TEST_MAIN(JSON) -- cgit v1.2.3