mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 20:55:35 +03:00
AK: Make JsonValue::from_string("") return a null JsonValue
This unbreaks the /var/run/utmp system which starts out as an empty string, and is then turned into an object by the first update. This isn't necessarily the best way for this to work, but it's how it used to work, so this just fixes the regression for now.
This commit is contained in:
parent
b38f8902d2
commit
a409b832fa
Notes:
sideshowbarker
2024-07-17 22:41:17 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/a409b832fac
@ -230,6 +230,8 @@ void JsonValue::clear()
|
||||
#ifndef KERNEL
|
||||
ErrorOr<JsonValue> JsonValue::from_string(StringView input)
|
||||
{
|
||||
if (input.is_empty())
|
||||
return JsonValue();
|
||||
return JsonParser(input).parse();
|
||||
}
|
||||
#endif
|
||||
|
@ -122,3 +122,9 @@ TEST_CASE(json_u64_roundtrip)
|
||||
EXPECT_EQ_FORCE(value.is_error(), false);
|
||||
EXPECT_EQ(value.value().as_u64(), big_value);
|
||||
}
|
||||
|
||||
TEST_CASE(json_parse_empty_string)
|
||||
{
|
||||
auto value = JsonValue::from_string("");
|
||||
EXPECT_EQ(value.value().is_null(), true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user