Skip to content

[Yaml] CRLF multiline strings not dumpped as scalar blocks #38171

@occanowey

Description

@occanowey

Symfony version(s) affected: 3.4.37+, 4.3.10+, 4.4.2+, 5.0.2+

Description
As of #34449 when using Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK any multiline string with CRLF new lines will be encoded as a single line quoted string instead of a scalar block.

How to reproduce
Try to dump a string with CRLF new lines.

e.g.

$strings = [
    "lf" => "multi\nline\nstring",
    "crlf" => "multi\r\nline\r\nstring",
    "mixed" => "multi\r\nline\nstring",
];

$yaml = Yaml::dump($strings, 2, 2, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
print($yaml);

produces:

lf: |
  multi
  line
  string
crlf: "multi\r\nline\r\nstring"
mixed: "multi\r\nline\nstring"

Possible Solution
Change explode back to preg_split, but I'm unsure it explode was used for a specific reason.

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy