-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] parse inlined tags without values #23757
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
Conversation
xabbuh
commented
Aug 2, 2017
Q | A |
---|---|
Branch? | master |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | |
License | MIT |
Doc PR |
Tag values are always strings as they are not evaluated, I don't think this change makes sense. |
{ | ||
if ('!' !== $value[$i]) { | ||
return; | ||
} | ||
|
||
$tagLength = strcspn($value, " \t\n", $i + 1); | ||
$tagLength = strcspn($value, " \t\n".$stopOn, $i + 1); |
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.
In fact indicators must always be forbidden in tags handle (see http://www.yaml.org/spec/1.2/spec.html#ns-tag-char).
It should be done in 3.3 as a bug fix imo.
I didn't find anything in the specs that forbids having a tag without a value. Did I miss anything? |
at least http://yaml-online-parser.appspot.com/ forbids it |
http://yaml-online-parser.appspot.com/ is buggy then :)
Having a tag without a value is allowed, I'm just saying the value is not Edit: the only thing we should change is forbidding indicators in a tag name. |
OK, it's not buggy, it's that a space is required after the tag, and then it resolves to the empty string yes. |
@nicolas-grekas the reference is http://ben-kiki.org/ypaste/data/497/index.html :)
|
cc56340
to
75d6f5b
Compare
tags without values are now getting parsed as empty strings (their values are parsed as empty strings) |
{ | ||
if ('!' !== $value[$i]) { | ||
return; | ||
} | ||
|
||
$tagLength = strcspn($value, " \t\n", $i + 1); | ||
$tagLength = strcspn($value, " \t\n".$stopOn, $i + 1); |
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.
Imo this function should just be updated to:
private static function parseTag($value, &$i, $flags)
{
if ('!' !== $value[$i]) {
return;
}
$tagLength = strcspn($value, " \t\n,[]{}", $i + 1);
// ...
Let's wait here until we have merged #22913 so we can indeed forbid indicator characters in tags (as written in #23757 (comment)). Currently, we cannot do that because we would then break parsing the |
75d6f5b
to
d67e1dd
Compare
rebased and ready |
d67e1dd
to
3bb0a3f
Compare
This PR was merged into the 4.0-dev branch. Discussion ---------- [Yaml] parse inlined tags without values | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 3bb0a3f [Yaml] parse inlined tags without values