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

Conversation

azat
Copy link

@azat azat commented Dec 22, 2024

Previously documents like the following was simply ignored:

----
# foo
bar: bam

Previously documents like the following was simply ignored:

    ----
    # foo
    bar: bam
Copy link
Owner

@jbeder jbeder left a comment

Choose a reason for hiding this comment

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

I think there is a bug, but I don't think this is the correct fix - right now, the behavior is correct for the following cases:

$ echo '----' | ./util/parse
----

This correctly parses it as a single scalar node "----". I suspect this will be incorrect with your solution.

$ echo '----\nfoo: bar' | ./util/parse
yaml-cpp: error at line 2, column 4: illegal map value

This is your first test - it's properly marked as an error in the existing code, and I think it may switch to the wrong error in your code.

However:

$ echo '----\n# foo\nbaz: 1' | ./util/parse
----

This is your second test, and this is wrong, as you point out; it should be an error.

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants