8000 bug #38229 [Yaml] fix parsing comments not prefixed by a space (xabbuh) · symfony/symfony@74f41f3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 74f41f3

Browse files
committed
bug #38229 [Yaml] fix parsing comments not prefixed by a space (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [Yaml] fix parsing comments not prefixed by a space | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #38223 | License | MIT | Doc PR | Commits ------- 35b223a fix parsing comments not prefixed by a space
2 parents ba65757 + 35b223a commit 74f41f3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static function parse($value, $flags = 0, $references = [])
127127
}
128128

129129
// some comments are allowed at the end
130-
if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
130+
if (preg_replace('/\s*#.*$/A', '', substr($value, $i))) {
131131
throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
132132
}
133133

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,4 +860,14 @@ public function testParseNegativeOctalNumberContainingInvalidDigits()
860860
{
861861
self::assertSame('-0123456789', Inline::parse('-0123456789'));
862862
}
863+
864+
public function testParseCommentNotPrefixedBySpaces()
865+
{
866+
self::assertSame('foo', Inline::parse('"foo"#comment'));
867+
}
868+
869+
public function testParseUnquotedStringContainingHashTagNotPrefixedBySpace()
870+
{
871+
self::assertSame('foo#nocomment', Inline::parse('foo#nocomment'));
872+
}
863873
}

0 commit comments

Comments
 (0)
0