8000 [Yaml] removed parsing of non-escaped backslash in a double-quoted st… · symfony/symfony@558ddaa · GitHub
[go: up one dir, main page]

Skip to content

Commit 558ddaa

Browse files
committed
[Yaml] removed parsing of non-escaped backslash in a double-quoted string
1 parent 133bd0a commit 558ddaa

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/Symfony/Component/Yaml/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* Yaml::parse() now throws an exception when a blackslash is not escaped
8+
in double-quoted strings
9+
410
2.8.0
511
-----
612

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo
7171
}
7272

7373
/**
74-
* @group legacy
75-
* throws \Symfony\Component\Yaml\Exception\ParseException in 3.0
74+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
7675
*/
7776
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
7877
{
79-
$this->assertSame('Foo\Var', Inline::parse('"Foo\Var"'));
78+
Inline::parse('"Foo\Var"');
8079
}
8180

8281
/**

src/Symfony/Component/Yaml/Unescaper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Yaml;
1313

14+
use Symfony\Component\Yaml\Exception\ParseException;
15+
1416
/**
1517
* Unescaper encapsulates unescaping rules for single and double-quoted
1618
* YAML strings.
@@ -63,7 +65,7 @@ public function unescapeDoubleQuotedString($value)
6365
* @internal This method is public to be usable as callback. It should not
6466
* be used in user code. Should be changed in 3.0.
6567
*/
66-
public function unescapeCharacter($value)
68+
private function unescapeCharacter($value)
6769
{
6870
switch ($value[1]) {
6971
case '0':
@@ -113,9 +115,7 @@ public function unescapeCharacter($value)
113115
case 'U':
114116
return self::utf8chr(hexdec(substr($value, 2, 8)));
115117
default:
116-
@trigger_error('Not escaping a backslash in a double-quoted string is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', E_USER_DEPRECATED);
117-
118-
return $value;
118+
throw new ParseException(sprintf('Found unknown escape character (%s in \\%s).', $value, $value));
119119
}
120120
}
121121

0 commit comments

Comments
 (0)
0