Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Yaml] Wrong comment removal inside a string block #15857

Closed
@ogizanagi

Description

@ogizanagi

Adding the following test in src/Symfony/Component/Yaml/Tests/ParserTest.php would fail:

2.3...ogizanagi:yaml/ignored_comments

    public function testSecondLevelFoldedStringBlockWithComments()
    {
        $this->assertEquals(array(
            'pages' => array(
                array(
                    'title' => 'some title',
                    'content' => <<<EOT
# comment 1
header

    # comment 2
    <body>
        <h1>title</h1>
    </body>

footer # comment3
EOT
                ),
            ),
        ), Yaml::parse(<<<EOF
pages:
    -
        title: some title
        content: |
            # comment 1
            header

                # comment 2
                <body>
                    <h1>title</h1>
                </body>

            footer # comment3
EOF
        ));
    }
There was 1 failure:

1) Symfony\Component\Yaml\Tests\ParserTest::testSecondLevelFoldedStringBlockWithComments
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     'pages' => Array (
         0 => Array (
             'title' => 'some title'
-            'content' => '# comment 1
-            header
+            'content' => 'header

-                # comment 2
                 <body>
                     <h1>title</h1>
                 </body>

             footer # comment3'
         )
     )
 )

Such situations should already have been solved by #8472 and #8841.
Sadly, it's seems not to be sufficient when dealing with keys at a deeper level. :/

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