Skip to content

[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

Merged
merged 1 commit into from
Aug 10, 2017

Conversation

xabbuh
Copy link
Member

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

@GuilhemN
Copy link
Contributor

GuilhemN commented Aug 2, 2017

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);
Copy link
Contributor

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.

@xabbuh
Copy link
Member Author

xabbuh commented Aug 2, 2017

Tag values are always strings as they are not evaluated, I don't think this change makes sense.

I didn't find anything in the specs that forbids having a tag without a value. Did I miss anything?

@nicolas-grekas
Copy link
Member

at least http://yaml-online-parser.appspot.com/ forbids it

@GuilhemN
Copy link
Contributor

GuilhemN commented Aug 2, 2017

http://yaml-online-parser.appspot.com/ is buggy then :)

I didn't find anything in the specs that forbids having a tag without a value. Did I miss anything?

Having a tag without a value is allowed, I'm just saying the value is not null then but "".

Edit: the only thing we should change is forbidding indicators in a tag name.

@nicolas-grekas
Copy link
Member

OK, it's not buggy, it's that a space is required after the tag, and then it resolves to the empty string yes.

@GuilhemN
Copy link
Contributor

GuilhemN commented Aug 3, 2017

@nicolas-grekas the reference is http://ben-kiki.org/ypaste/data/497/index.html :)

} is forbidden in tag names so the parser should properly know that the tag is ended and should not need a space.

@xabbuh xabbuh force-pushed the yaml-empty-tag-values branch from cc56340 to 75d6f5b Compare August 3, 2017 09:22
@xabbuh
Copy link
Member Author

xabbuh commented Aug 3, 2017

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);
Copy link
Contributor

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);

        // ...

@xabbuh
Copy link
Member Author

xabbuh commented Aug 4, 2017

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 !php/object tag.

@GuilhemN
Copy link
Contributor

GuilhemN commented Aug 6, 2017

#22913 and #23790 have been merged :)

@xabbuh xabbuh force-pushed the yaml-empty-tag-values branch from 75d6f5b to d67e1dd Compare August 7, 2017 11:00
@xabbuh
Copy link
Member Author

xabbuh commented Aug 7, 2017

rebased and ready

@xabbuh xabbuh force-pushed the yaml-empty-tag-values branch from d67e1dd to 3bb0a3f Compare August 7, 2017 11:31
@xabbuh xabbuh merged commit 3bb0a3f into symfony:master Aug 10, 2017
xabbuh added a commit that referenced this pull request Aug 10, 2017
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
@xabbuh xabbuh deleted the yaml-empty-tag-values branch August 10, 2017 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants