Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Yaml Parser] fixed Parser to skip comments when inlining sequences #38040

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
Sep 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Yaml Parser] fixed Parser to skip comments when inlining sequences
  • Loading branch information
korve authored and fabpot committed Sep 6, 2020
commit b5316ebebb42bfe7b755bb208b84903f55b16a32
8 changes: 7 additions & 1 deletion 8 src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,13 @@ private function lexInlineSequence(string $yaml): string
for ($i = 1; isset($this->currentLine[$i]) && ']' !== $this->currentLine[$i]; ++$i) {
}

$value .= trim($this->currentLine);
$trimmedValue = trim($this->currentLine);

if ('' !== $trimmedValue && '#' === $trimmedValue[0]) {
continue;
}

$value .= $trimmedValue;

if (isset($this->currentLine[$i]) && ']' === $this->currentLine[$i]) {
break;
Expand Down
24 changes: 24 additions & 0 deletions 24 src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,30 @@ public function taggedValuesProvider()
[new TaggedValue('foo', 'bar')],
'[ !foo bar ]',
],
'with-comments' => [
[
[new TaggedValue('foo', ['foo', 'baz'])],
],
<<<YAML
- [!foo [
foo,
baz
#bar
]]
YAML
],
'with-comments-trailing-comma' => [
Copy link
Member

Choose a reason for hiding this comment

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

I fail to see how this test case differs from the previous one.

Copy link
Contributor Author

@korve korve Sep 6, 2020

Choose a reason for hiding this comment

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

Oops you're right. The 'with-comments' was meant to be without a comma after the 2nd array element. I've fixed it.

[
[new TaggedValue('foo', ['foo', 'baz'])],
],
<<<YAML
- [!foo [
foo,
baz,
#bar
]]
YAML
],
];
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.