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::dump adds erroneous trailing \n (with Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK) #38310

Copy link
Copy link
Closed
@geek-merlin

Description

@geek-merlin
Issue body actions

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

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