diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index b4a7072228e9b..ec3392161447c 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -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); diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 35cd6b73aad20..22a3964809144 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -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}'); + } }