From 71cec8203f7745aa922653afc9b7451a18955613 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Wed, 22 Mar 2017 10:36:03 +0100 Subject: [PATCH] [Yaml] Fix error handling in parser --- src/Symfony/Component/Yaml/Parser.php | 2 +- src/Symfony/Component/Yaml/Tests/ParserTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index be72697bd3393..8f38d882af19e 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -341,7 +341,7 @@ public function parse($value, $flags = 0) try { $parsedLine = Inline::parse($line, $flags, $this->refs); - if (!is_string($value)) { + if (!is_string($parsedLine)) { $parseError = true; break; } diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 38e2f78e41798..e4633196b21dc 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -1687,6 +1687,21 @@ public function testComplexMappingNestedInSequenceThrowsParseException() $this->parser->parse($yaml); } + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage Unable to parse at line 1 (near "[parameters]"). + */ + public function testParsingIniThrowsException() + { + $ini = <<parser->parse($ini); + } + private function loadTestsFromFixtureFiles($testsFile) { $parser = new Parser();