bug #22853 [Yaml] fix multiline block handling (xabbuh)
This PR was merged into the 3.3 branch.
Discussion
----------
[Yaml] fix multiline block handling
| Q | A
| ------------- | ---
| Branch? | 3.3
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #21114, https://github.com/symfony/symfony/pull/22105#issuecomment-288386147
| License | MIT
| Doc PR |
Commits
-------
a2079d6e2e
[Yaml] fix multiline block handling
This commit is contained in:
commit
047a06e235
@ -368,7 +368,11 @@ class Parser
|
||||
|
||||
foreach ($this->lines as $line) {
|
||||
try {
|
||||
$parsedLine = Inline::parse($line, $flags, $this->refs);
|
||||
if (isset($line[0]) && ('"' === $line[0] || "'" === $line[0])) {
|
||||
$parsedLine = $line;
|
||||
} else {
|
||||
$parsedLine = Inline::parse($line, $flags, $this->refs);
|
||||
}
|
||||
|
||||
if (!is_string($parsedLine)) {
|
||||
$parseError = true;
|
||||
|
@ -1561,8 +1561,18 @@ EOT;
|
||||
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
|
||||
}
|
||||
|
||||
public function testParseMultiLineMappingValue()
|
||||
/**
|
||||
* @dataProvider multiLineDataProvider
|
||||
*/
|
||||
public function testParseMultiLineMappingValue($yaml, $expected, $parseError)
|
||||
{
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function multiLineDataProvider()
|
||||
{
|
||||
$tests = array();
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
foo:
|
||||
- bar:
|
||||
@ -1579,7 +1589,43 @@ EOF;
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml));
|
||||
$tests[] = array($yaml, $expected, false);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
bar
|
||||
"foo"
|
||||
EOF;
|
||||
$expected = 'bar "foo"';
|
||||
|
||||
$tests[] = array($yaml, $expected, false);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
bar
|
||||
"foo
|
||||
EOF;
|
||||
$expected = 'bar "foo';
|
||||
|
||||
$tests[] = array($yaml, $expected, false);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
bar
|
||||
|
||||
'foo'
|
||||
EOF;
|
||||
$expected = "bar\n'foo'";
|
||||
|
||||
$tests[] = array($yaml, $expected, false);
|
||||
|
||||
$yaml = <<<'EOF'
|
||||
bar
|
||||
|
||||
foo'
|
||||
EOF;
|
||||
$expected = "bar\nfoo'";
|
||||
|
||||
$tests[] = array($yaml, $expected, false);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
public function testTaggedInlineMapping()
|
||||
|
Reference in New Issue
Block a user