Skip to content

Commit

Permalink
bug #20335 [Yaml] Fix String offset cast error in Inline parser (roma…
Browse files Browse the repository at this point in the history
…inneutron)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Yaml] Fix String offset cast error in Inline parser

| Q | A |
| --- | --- |
| Branch? | 3.2/master |
| Bug fix? | yes |
| New feature? | no |
| BC breaks? | no |
| Deprecations? | no |
| Tests pass? | yes |
| Fixed tickets | N/A |
| License | MIT |

Commits
-------

bc095a5 [Yaml] Fix String offset cast error in Inline parser
  • Loading branch information
fabpot committed Nov 2, 2016
2 parents fedbc3f + bc095a5 commit a257cb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Symfony/Component/Yaml/Inline.php
Expand Up @@ -458,7 +458,10 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar

// key
$key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
$i = strpos($mapping, ':', $i);

if (false === $i = strpos($mapping, ':', $i)) {
break;
}

if (!isset($mapping[$i + 1]) || ' ' !== $mapping[$i + 1]) {
@trigger_error('Omitting the space after the colon that follows a mapping key definition is deprecated since version 3.2 and will throw a ParseException in 4.0.', E_USER_DEPRECATED);
Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/Yaml/Tests/InlineTest.php
Expand Up @@ -654,4 +654,13 @@ public function getInvalidBinaryData()
'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
);
}

/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
* @expectedExceptionMessage Malformed inline YAML string {this, is not, yaml}
*/
public function testStringOffsetCastError()
{
Inline::parse('{this, is not, yaml}');
}
}

0 comments on commit a257cb5

Please sign in to comment.