8000 [Yaml] Fix error handling in parser · symfony/symfony@71cec82 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71cec82

Browse files
committed
[Yaml] Fix error handling in parser
1 parent 3495b35 commit 71cec82

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Symfony/Component/Yaml/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public function parse($value, $flags = 0)
341341
try {
342342
$parsedLine = Inline::parse($line, $flags, $this->refs);
343343

344-
if (!is_string($value)) {
344+
if (!is_string($parsedLine)) {
345345
$parseError = true;
346346
break;
347347
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,21 @@ public function testComplexMappingNestedInSequenceThrowsParseException()
16871687
$this->parser->parse($yaml);
16881688
}
16891689

1690+
/**
1691+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
1692+
* @expectedExceptionMessage Unable to parse at line 1 (near "[parameters]").
1693+
*/
1694+
public function testParsingIniThrowsException()
1695+
{
1696+
$ini = <<<INI
1697+
[parameters]
1698+
foo = bar
1699+
bar = %foo%
1700+
INI;
1701+
1702+
$this->parser->parse($ini);
1703+
}
1704+
16901705
private function loadTestsFromFixtureFiles($testsFile)
16911706
{
16921707
$parser = new Parser();

0 commit comments

Comments
 (0)
0