From 35b223aaa4e5bf4146179838b5fa7a26979df375 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 18 Sep 2020 10:50:51 +0200 Subject: [PATCH] fix parsing comments not prefixed by a space --- src/Symfony/Component/Yaml/Inline.php | 2 +- src/Symfony/Component/Yaml/Tests/InlineTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index 5f8fd55c793be..64ac48a9c618c 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -127,7 +127,7 @@ public static function parse($value, $flags = 0, $references = []) } // some comments are allowed at the end - if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) { + if (preg_replace('/\s*#.*$/A', '', substr($value, $i))) { throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename); } diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index d1eb2f7a5de76..f64cc682c3d91 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -860,4 +860,14 @@ public function testParseNegativeOctalNumberContainingInvalidDigits() { self::assertSame('-0123456789', Inline::parse('-0123456789')); } + + public function testParseCommentNotPrefixedBySpaces() + { + self::assertSame('foo', Inline::parse('"foo"#comment')); + } + + public function testParseUnquotedStringContainingHashTagNotPrefixedBySpace() + { + self::assertSame('foo#nocomment', Inline::parse('foo#nocomment')); + } } 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