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