Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit74f41f3

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 parentsba65757 +35b223a commit74f41f3

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
thrownewParseException(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+
publicfunctiontestParseCommentNotPrefixedBySpaces()
865+
{
866+
self::assertSame('foo', Inline::parse('"foo"#comment'));
867+
}
868+
869+
publicfunctiontestParseUnquotedStringContainingHashTagNotPrefixedBySpace()
870+
{
871+
self::assertSame('foo#nocomment', Inline::parse('foo#nocomment'));
872+
}
863873
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp