-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Yaml] fixed parse shortcut Key after unindented collection. #13352
Conversation
aitboudad
commented
Jan 10, 2015
Q | A |
---|---|
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Fixed tickets | #13345, #8093, #11019 and #10885 |
Tests pass? | yes |
License | MIT |
@@ -336,7 +336,8 @@ private function getNextEmbedBlock($indentation = null, $inSequence = false) | |||
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine); | |||
} | |||
|
|||
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { | |||
$isStringUnIndentedShortcutKey = (2 === ($indent - $newIndent)); |
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.
What would happen if the YAML string actually were?
collection:
- key: foo
foo: bar
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.
"Unable to parse at line 3 (near " foo: bar")
I think it's another case not supported yet, even:
collection:
- key: foo
foo: bar
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.
@xabbuh event it not related to this PR, here is another issue:
collection:
- key: foo
Excepted:
{
"collection": [
{
"key": "foo"
}
]
}
But given:
{
"collection": [
{
"key: foo"
}
]
}
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.
@aitboudad Honestly, I don't see a (semantical) difference between your two examples.
Could we remeber the number of spaces between the dash and the list item when detecting such constructs to not use a hard-coded value of 2
here?
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.
@xabbuh the value is hard-coded here https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Yaml/Parser.php#L111 can you see now is it ok ?
3a1c8c1
to
664cf91
Compare
664cf91
to
58a7426
Compare
@fabpot please ignore the Yaml test fixtures in fabbot (or refactor the Yaml testsuite to avoid using multiple documents in the same files) |
👍 |
Thanks for fixing this bug @aitboudad. |
…n. (aitboudad) This PR was merged into the 2.3 branch. Discussion ---------- [Yaml] fixed parse shortcut Key after unindented collection. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | #13345, #8093, #11019 and #10885 | Tests pass? | yes | License | MIT Commits ------- 58a7426 [Yaml] fixed parse shortcut Key after unindented collection.