bug #20335 [Yaml] Fix String offset cast error in Inline parser (romainneutron)

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
This commit is contained in:
Fabien Potencier 2016-11-02 07:03:22 -07:00
commit a257cb59ec
2 changed files with 13 additions and 1 deletions

View File

@ -458,7 +458,10 @@ class Inline
// 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);

View File

@ -654,4 +654,13 @@ class InlineTest extends \PHPUnit_Framework_TestCase
'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}');
}
}