Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a257cb5

Browse files
committed
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
2 parents fedbc3f + bc095a5 commit a257cb5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,10 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
458458

459459
// key
460460
$key = self::parseScalar($mapping, $flags, array(':', ' '), array('"', "'"), $i, false);
461-
$i = strpos($mapping, ':', $i);
461+
462+
if (false === $i = strpos($mapping, ':', $i)) {
463+
break;
464+
}
462465

463466
if (!isset($mapping[$i + 1]) || ' ' !== $mapping[$i + 1]) {
464467
@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);

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,13 @@ public function getInvalidBinaryData()
654654
'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
655655
);
656656
}
657+
658+
/**
659+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
660+
* @expectedExceptionMessage Malformed inline YAML string {this, is not, yaml}
661+
*/
662+
public function testStringOffsetCastError()
663+
{
664+
Inline::parse('{this, is not, yaml}');
665+
}
657666
}

0 commit comments

Comments
 (0)