Skip to content

Commit

Permalink
minor #22105 [Yaml] Fix error handling on ini file parsing (chalasr)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.3-dev branch.

Discussion
----------

[Yaml] Fix error handling on ini file parsing

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Should make travis green again on master.
/cc @xabbuh

Commits
-------

71cec82 [Yaml] Fix error handling in parser
  • Loading branch information
xabbuh committed Mar 22, 2017
2 parents 3495b35 + 71cec82 commit daac6c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -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;
}
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Component/Yaml/Tests/ParserTest.php
Expand Up @@ -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 = <<<INI
[parameters]
foo = bar
bar = %foo%
INI;

$this->parser->parse($ini);
}

private function loadTestsFromFixtureFiles($testsFile)
{
$parser = new Parser();
Expand Down

0 comments on commit daac6c2

Please sign in to comment.