Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid incorrect document start (---) #1333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/exp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 10 additions & 0 deletions test/integration/handler_spec_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1682,5 +1682,15 @@ TEST_F(HandlerSpecTest, Ex8_22_BlockCollectionNodes) {
EXPECT_CALL(handler, OnDocumentEnd());
Parse(ex8_22);
}

TEST_F(HandlerSpecTest, InvalidDocStart1) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put these tests in parser_test.cpp - the spec tests are just for examples explicitly given in the spec.

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