From 4f13a76ce80380afc465e899d64dbf16f9b915d8 Mon Sep 17 00:00:00 2001 From: Joschi Kuphal Date: Sat, 11 Jun 2016 11:46:35 +0200 Subject: [PATCH 1/2] [YAML] Fixed parsing problem with nested DateTime lists --- src/Symfony/Component/Yaml/Inline.php | 2 +- src/Symfony/Component/Yaml/Tests/InlineTest.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index aab8fe3458f80..4c321f493cd39 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -397,7 +397,7 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references = $value = self::parseScalar($sequence, $flags, array(',', ']'), array('"', "'"), $i, true, $references); // the value can be an array if a reference has been resolved to an array var - if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) { + if (!is_array($value) && !$value instanceof \DateTimeInterface && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { $pos = 0; diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 05e58ca92b373..c231a6e37d0e3 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -524,6 +524,22 @@ public function getTimestampTests() ); } + /** + * @dataProvider getTimestampTests + */ + public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second) + { + $expected = new \DateTime($yaml); + $expected->setTimeZone(new \DateTimeZone('UTC')); + $expected->setDate($year, $month, $day); + $expected->setTime($hour, $minute, $second); + + $expectedNested = array('nested' => array($expected)); + $yamlNested = "{nested: [$yaml]}"; + + $this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME)); + } + /** * @dataProvider getDateTimeDumpTests */ From 0f47712f532174c3afb256afdfd5901dadaf9382 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 17 Jun 2016 16:16:22 +0200 Subject: [PATCH 2/2] parse embedded mappings only if value is a string --- src/Symfony/Component/Yaml/Inline.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 4c321f493cd39..95d9a90963347 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -397,7 +397,7 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references = $value = self::parseScalar($sequence, $flags, array(',', ']'), array('"', "'"), $i, true, $references); // the value can be an array if a reference has been resolved to an array var - if (!is_array($value) && !$value instanceof \DateTimeInterface && !$isQuoted && false !== strpos($value, ': ')) { + if (is_string($value) && !$isQuoted && false !== strpos($value, ': ')) { // embedded mapping? try { $pos = 0; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy