Skip to content

Commit 5dbf6bc

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

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ 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
75+
* @expectedExceptionMessage Found unknown escape character "\V".
7676
*/
7777
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
7878
{
79-
$this->assertSame('Foo\Var', Inline::parse('"Foo\Var"'));
79+
Inline::parse('"Foo\Var"');
8080
}
8181

8282
/**

src/Symfony/Component/Yaml/Unescaper.php

Lines changed: 4 additions & 7 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.
@@ -59,11 +61,8 @@ public function unescapeDoubleQuotedString($value)
5961
* @param string $value An escaped character
6062
*
6163
* @return string The unescaped character
62-
*
63-
* @internal This method is public to be usable as callback. It should not
64-
* be used in user code. Should be changed in 3.0.
6564
*/
66-
public function unescapeCharacter($value)
65+
private function unescapeCharacter($value)
6766
{
6867
switch ($value[1]) {
6968
case '0':
@@ -113,9 +112,7 @@ public function unescapeCharacter($value)
113112
case 'U':
114113
return self::utf8chr(hexdec(substr($value, 2, 8)));
115114
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;
115+
throw new ParseException(sprintf('Found unknown escape character "%s".', $value));
119116
}
120117
}
121118

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy