Fix crash when parsing {x:

Signed-off-by: Raul Gutierrez Segales <rgs@pinterest.com>
This commit is contained in:
Raul Gutierrez Segales 2020-05-22 17:09:39 -04:00
parent d9c35b6079
commit 3cb6578f02
2 changed files with 6 additions and 1 deletions

View File

@ -155,7 +155,7 @@ inline const RegEx& PlainScalar() {
inline const RegEx& PlainScalarInFlow() {
static const RegEx e =
!(BlankOrBreak() | RegEx("?,[]{}#&*!|>\'\"%@`", REGEX_OR) |
(RegEx("-:", REGEX_OR) + Blank()));
(RegEx("-:", REGEX_OR) + (Blank() | RegEx())));
return e;
}
inline const RegEx& EndScalar() {

View File

@ -1127,5 +1127,10 @@ TEST(NodeSpecTest, Ex8_22_BlockCollectionNodes) {
EXPECT_EQ(1, doc["mapping"].size());
EXPECT_EQ("bar", doc["mapping"]["foo"].as<std::string>());
}
TEST(NodeSpecTest, FlowMapNotClosed) {
EXPECT_THROW_PARSER_EXCEPTION(Load("{x:"), ErrorMsg::UNKNOWN_TOKEN);
}
}
}