-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix issue740: parse colon in plain scalar correctly #911
Conversation
The spec ns-plain-char says:
That means, I believe, that for example a colon followed by a comma or another flow-indicator will end a plain scalar in flow.
But this is valid (it's an example in the spec after all), and part of the YAML Test Suite: |
Ok, I see. @perlpunk ,thanks for your explaination. I have a misunderstanding about this and confuse the |
test/specexamples.h
Outdated
@@ -641,8 +641,8 @@ const char *ex7_17 = | |||
"{\n" | |||
"unquoted : \"separate\",\n" | |||
"http://foo.com,\n" | |||
"omitted value:,\n" | |||
": omitted key,\n" | |||
"omitted value: ,\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have a closer look at the spec example 7.17, you'll notice that it contains
omitted value:°,
where the °
stands for the empty node, so it should not be replaced with a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha-ha, yes. And if one is not careless, it's easy to confuse them, just like me.
It would be cool to fix #899 though. |
ok, I will solve this problem as soon as possible |
@perlpunk Should processor throw an exception when it parses the |
@dota17 it is actually an edge case. Edit: and as an additional note, empty implicit keys will very probably be removed in the next YAML version, so this case will become invalid anyway. |
Update the solution and testcases for the bug in issue741/899. The previous solution has been deleted. |
According to the yaml specification, a colon can be seen as a part of a plain scalar if it is not followed by white space in most cases.
yaml-cpp/src/exp.h
Line 167 in 3f381f1
In function EndScalarInFlow() ,
RegEx(':')+RegEx(",]}", REGEX_OR)
means if a ":" is followed by a "," or " ] " or " }", the ":" will not be a part of a plain scalar. It is against the spec, so I removed it, and this solved the problem of #740 and #899.*ex7_3
and*ex7_17
inspecexamples.h
have a little difference with the spec content, This difference will cause the corresponding testcases can't work as expected because of the new rule. I changed them to be the same as spec.