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

Skip to content

Commit 5f54121

Browse files
committed
[Yaml] deprecate unquoted indicator characters
1 parent 5805cc5 commit 5f54121

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ public static function parseScalar($scalar, $delimiters = null, $stringDelimiter
236236
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
237237
}
238238

239-
// a non-quoted string cannot start with @ or ` (reserved)
240-
if ($output && ('@' === $output[0] || '`' === $output[0])) {
239+
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
240+
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) {
241241
@trigger_error(sprintf('Not quoting a scalar starting with "%s" is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $output[0]), E_USER_DEPRECATED);
242242

243243
// to be thrown in 3.0

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ test: Some characters at the beginning of a string must be escaped
33
brief: >
44
Some characters at the beginning of a string must be escaped
55
yaml: |
6-
foo: | bar
6+
foo: '| bar'
77
php: |
88
array('foo' => '| bar')
99
---

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,21 @@ public function getReservedIndicators()
205205
return array(array('@'), array('`'));
206206
}
207207

208+
/**
209+
* @group legacy
210+
* @dataProvider getScalarIndicators
211+
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
212+
*/
213+
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
214+
{
215+
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
216+
}
217+
218+
public function getScalarIndicators()
219+
{
220+
return array(array('|'), array('>'));
221+
}
222+
208223
public function getTestsForParse()
209224
{
210225
return array(

0 commit comments

Comments
 (0)