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

Skip to content

Yaml::dump adds erroneous trailing \n (with Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK) #38310

Closed
@geek-merlin

Description

@geek-merlin

Symfony version(s) affected: 3.4.41 (and probably master too)

Description

Yaml::parse(Yaml::dump("a\nb")) === "a\nb\n"

In other words, multiline YML does not roundtrip, it seems to always get a trailing newline.

How to reproduce

# In my Drupal/Drush env:
$ drush ev 'print json_encode(\Symfony\Component\Yaml\Yaml::parse(\Symfony\Component\Yaml\Yaml::dump(["a\nb"],2,4, \Symfony\Component\Yaml\Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK))) . "\n";'
["a\nb\n"]

Possible Solution

Add such test and fix code.

Additional context

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