Forbid incorrect document start (---)
Previously documents like the following was simply ignored:
----
# foo
bar: bam
This commit is contained in:
parent
76dc671573
commit
3a1070d061
@ -82,7 +82,7 @@ inline const RegEx& Utf8_ByteOrderMark() {
|
||||
// actual tags
|
||||
|
||||
inline const RegEx& DocStart() {
|
||||
static const RegEx e = RegEx("---") + (BlankOrBreak() | RegEx());
|
||||
static const RegEx e = RegEx("---");
|
||||
return e;
|
||||
}
|
||||
inline const RegEx& DocEnd() {
|
||||
|
||||
@ -1682,5 +1682,15 @@ TEST_F(HandlerSpecTest, Ex8_22_BlockCollectionNodes) {
|
||||
EXPECT_CALL(handler, OnDocumentEnd());
|
||||
Parse(ex8_22);
|
||||
}
|
||||
|
||||
TEST_F(HandlerSpecTest, InvalidDocStart1) {
|
||||
EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse("----\nbaz: 1"),
|
||||
ErrorMsg::BLOCK_ENTRY);
|
||||
}
|
||||
TEST_F(HandlerSpecTest, InvalidDocStart2) {
|
||||
EXPECT_THROW_PARSER_EXCEPTION(IgnoreParse("----\n# foo\nbaz: 1"),
|
||||
ErrorMsg::BLOCK_ENTRY);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace YAML
|
||||
|
||||
Loading…
Reference in New Issue
Block a user