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

Skip to content

Commit 4fb5c12

Browse files
committed
[Yaml] Allow tabs before comments at the end of a line
In Yaml 1.2 spec white space is space or tab
1 parent 6316de5 commit 4fb5c12

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
209209
$i += strlen($output);
210210

211211
// remove comments
212-
if (false !== $strpos = strpos($output, ' #')) {
212+
if ((false !== $strpos = strpos($output, ' #')) || (false !== $strpos = strpos($output, "\t#"))) {
213213
$output = rtrim(substr($output, 0, $strpos));
214214
}
215215
} elseif (preg_match('/^(.+?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {

src/Symfony/Component/Yaml/Tests/Fixtures/sfComments.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ yaml: |
77
ex2: "foo # bar" # comment
88
ex3: 'foo # bar' # comment
99
ex4: foo # comment
10+
ex5: foo # comment with tab before
11+
ex6: foo#foo # comment here
1012
php: |
11-
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
13+
array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo', 'ex6' => 'foo#foo')
1214
---
1315
test: Comments in the middle
1416
brief: >

0 commit comments

Comments
 (0)