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

Skip to content

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

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

Closed
ogizanagi opened this issue Sep 21, 2015 · 2 comments
Closed

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

ogizanagi opened this issue Sep 21, 2015 · 2 comments

Comments

@ogizanagi
Copy link
Contributor

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. :/

fabpot added a commit that referenced this issue Oct 1, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

[Yaml] Fix improper comments removal

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15857
| License       | MIT
| Doc PR        | -

This tries to fix #15857 .

Honestly, I don't have any idea of the regressions it might introduce. Tests are passing, so if this code had any reason to exist, tests covering it are certainly missing :/

Any hint ?

Commits
-------

0e24fc5 [Yaml] Fix improper comments removal inside strings
@fabpot fabpot closed this as completed Oct 1, 2015
@xabbuh
Copy link
Member

xabbuh commented Oct 2, 2015

Reopening as #15860 has been reverted due to a regression.

@xabbuh xabbuh reopened this Oct 2, 2015
fabpot added a commit that referenced this issue Oct 2, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

[Yaml] Add regression test for comments indents

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This is related to #16065, #15857 and #15860  (last one has been reverted due to this regression)

Commits
-------

7b9d519 [Yaml] Add regression test for comments indents
@fabpot fabpot added the Yaml label Oct 5, 2015
@xabbuh
Copy link
Member

xabbuh commented Dec 5, 2015

see #16860

@xabbuh xabbuh added the Bug label Dec 5, 2015
fabpot added a commit that referenced this issue Dec 18, 2015
This PR was merged into the 2.3 branch.

Discussion
----------

[Yaml] do not remove "comments" in scalar blocks

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12478, #15857
| License       | MIT
| Doc PR        |

Inside scalar blocks, lines starting with a `#` character must be
treated like every other strings and must not be ignored as comments.

Commits
-------

3c72fcc [Yaml] do not remove "comments" in scalar blocks
@fabpot fabpot closed this as completed Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants