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

Commit a2079d6

Browse filesBrowse files
committed
[Yaml] fix multiline block handling
1 parent 005b4b7 commit a2079d6
Copy full SHA for a2079d6

File tree

2 files changed

+53
-3
lines changed
Filter options

2 files changed

+53
-3
lines changed

‎src/Symfony/Component/Yaml/Parser.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Parser.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,11 @@ private function doParse($value, $flags)
368368

369369
foreach ($this->lines as $line) {
370370
try {
371-
$parsedLine = Inline::parse($line, $flags, $this->refs);
371+
if (isset($line[0]) && ('"' === $line[0] || "'" === $line[0])) {
372+
$parsedLine = $line;
373+
} else {
374+
$parsedLine = Inline::parse($line, $flags, $this->refs);
375+
}
372376

373377
if (!is_string($parsedLine)) {
374378
$parseError = true;

‎src/Symfony/Component/Yaml/Tests/ParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/ParserTest.php
+48-2Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,18 @@ public function testParseMultiLineString()
15611561
$this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
15621562
}
15631563

1564-
public function testParseMultiLineMappingValue()
1564+
/**
1565+
* @dataProvider multiLineDataProvider
1566+
*/
1567+
public function testParseMultiLineMappingValue($yaml, $expected, $parseError)
1568+
{
1569+
$this->assertEquals($expected, $this->parser->parse($yaml));
1570+
}
1571+
1572+
public function multiLineDataProvider()
15651573
{
1574+
$tests = array();
1575+
15661576
$yaml = <<<'EOF'
15671577
foo:
15681578
- bar:
@@ -1579,7 +1589,43 @@ public function testParseMultiLineMappingValue()
15791589
),
15801590
);
15811591

1582-
$this->assertEquals($expected, $this->parser->parse($yaml));
1592+
$tests[] = array($yaml, $expected, false);
1593+
1594+
$yaml = <<<'EOF'
1595+
bar
1596+
"foo"
1597+
EOF;
1598+
$expected = 'bar "foo"';
1599+
1600+
$tests[] = array($yaml, $expected, false);
1601+
1602+
$yaml = <<<'EOF'
1603+
bar
1604+
"foo
1605+
EOF;
1606+
$expected = 'bar "foo';
1607+
1608+
$tests[] = array($yaml, $expected, false);
1609+
1610+
$yaml = <<<'EOF'
1611+
bar
1612+
1613+
'foo'
1614+
EOF;
1615+
$expected = "bar\n'foo'";
1616+
1617+
$tests[] = array($yaml, $expected, false);
1618+
1619+
$yaml = <<<'EOF'
1620+
bar
1621+
1622+
foo'
1623+
EOF;
1624+
$expected = "bar\nfoo'";
1625+
1626+
$tests[] = array($yaml, $expected, false);
1627+
1628+
return $tests;
15831629
}
15841630

15851631
public function testTaggedInlineMapping()

0 commit comments

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