Skip to content

Yaml::parse() fails at double quoted multi line messages #11109

@MalteWunsch

Description

@MalteWunsch

The YAML specification has the following example for a multi line message in double quotes:

quoted: "So does this
  quoted scalar.\n"

Write that in a MultilineDoubleQuotedMessage.yml and try to Yaml::parse('MultilineDoubleQuotedMessage.yml') - Symfony will throw an exception like this:

Malformed inline YAML string ("So does this) in .../MultilineDoubleQuotedMessage.yml at line 1 (near "quoted: "So does this").

in .../symfony/symfony/src/Symfony/Component/Yaml/Inline.php at line 244
...

I tried that in Symfony 2.2.0 and 2.4.6, but the underlying issue seems to be the reg exp in https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Yaml/Inline.php#L246 , which lives on in Symfony 2.5.0.

A unit test in Symfony\Component\Yaml\Tests\YamlTest could look something like this:

public function testParseAcceptsMultilineDoubleQuotedMessage()
{
    $filename = __DIR__ . '/Fixtures/MultilineDoubleQuotedMessage.yml';
    $this->setExpectedException(null);
    Yaml::parse($filename);
}

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