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] Comments after blank lines are read as value #32667

Copy link
Copy link
Closed
@YujiSoftware

Description

@YujiSoftware
Issue body actions

Symfony version(s) affected: 3.4.27
I reproduce symfony/yaml@e464640

Description
Comments after blank lines are read as value in yaml.

How to reproduce

$yaml = <<<YAML
parameters:
    abc

# Comment 
YAML;

var_dump(Symfony\Component\Yaml\Yaml::parse($yaml));

Actual result:

array(1) {
  ["parameters"]=>
  string(13) "abc
# Comment"
}

Expected result:

array(1) {
  ["parameters"]=>
  string(3) "abc"
}

Possible Solution
Ignore comment line.

Additional context
When I tested some Online YAML parser, I got the expected results.
https://yaml-online-parser.appspot.com/?yaml=parameters%3A%0A++++abc%0A%0A%23+Comment%0A&type=json
http://nodeca.github.io/js-yaml/#yaml=cGFyYW1ldGVyczoKICAgIGFiYwoKIyBDb21tZW50IAo=

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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