Skip to content

Commit

Permalink
json: {"meow"} is not a valid object (microsoft#1130)
Browse files Browse the repository at this point in the history
* json: {"meow"} is not a valid object

* Add to contributors - eighteenth PR seemed like the time! :-)
  • Loading branch information
garethsb authored and parkske committed Apr 5, 2021
1 parent 3d8c9e5 commit 216db26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ leetal

Benjamin Lee (mobileben)
René Meusel (reneme)

Sony Corporation
Gareth Sylvester-Bradley (garethsb-sony)
2 changes: 1 addition & 1 deletion Release/src/json/json_parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ std::unique_ptr<web::json::details::_Value> JSON_Parser<CharType>::_ParseObject(
if (tkn.m_error) goto error;

// State 2: Looking for a colon.
if (tkn.kind != JSON_Parser<CharType>::Token::TKN_Colon) goto done;
if (tkn.kind != JSON_Parser<CharType>::Token::TKN_Colon) goto error;

GetNextToken(tkn);
if (tkn.m_error) goto error;
Expand Down
6 changes: 6 additions & 0 deletions Release/tests/functional/json/parsing_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,12 @@ SUITE(parsing_tests)
VERIFY_ARE_EQUAL(0u, arr.size());
}

TEST(bug_object_field_key_no_value)
{
VERIFY_PARSING_THROW(json::value::parse(U("{\"meow\"}")));
VERIFY_PARSING_THROW(json::value::parse(U("{\"meow\": 42, \"purr\": 57, \"hiss\"}")));
}

TEST(bug_416116)
{
json::value data2 = json::value::parse(U("\"δοκιμή\""));
Expand Down

0 comments on commit 216db26

Please sign in to comment.