summaryrefslogtreecommitdiff
path: root/AK/Tests
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-29 22:18:45 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-29 22:20:21 +0100
commit821484f170000e68114285b538c563be9858d119 (patch)
tree18a690f5360dbbb76dc8cc9bee696ab51b360c53 /AK/Tests
parentd1d7db274596c8a362a6fb877a75baa653a2e6f7 (diff)
downloadserenity-821484f170000e68114285b538c563be9858d119.zip
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!
Diffstat (limited to 'AK/Tests')
-rw-r--r--AK/Tests/TestJSON.cpp8
1 files changed, 8 insertions, 0 deletions
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)