From 5dbf6bc9b58731b63e80978d5990b7acfa19ed60 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 11 Oct 2015 14:23:49 +0200 Subject: [PATCH] [Yaml] removed parsing of non-escaped backslash in a double-quoted string --- src/Symfony/Component/Yaml/CHANGELOG.md | 6 ++++++ src/Symfony/Component/Yaml/Tests/InlineTest.php | 6 +++--- src/Symfony/Component/Yaml/Unescaper.php | 11 ++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Symfony/Component/Yaml/CHANGELOG.md b/src/Symfony/Component/Yaml/CHANGELOG.md index da735a1d8e2a3..fcac787e77122 100644 --- a/src/Symfony/Component/Yaml/CHANGELOG.md +++ b/src/Symfony/Component/Yaml/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +3.0.0 +----- + + * Yaml::parse() now throws an exception when a blackslash is not escaped + in double-quoted strings + 2.8.0 ----- diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 008f2f364c71f..e661108939fb3 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -71,12 +71,12 @@ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedTo } /** - * @group legacy - * throws \Symfony\Component\Yaml\Exception\ParseException in 3.0 + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + * @expectedExceptionMessage Found unknown escape character "\V". */ public function testParseScalarWithNonEscapedBlackslashShouldThrowException() { - $this->assertSame('Foo\Var', Inline::parse('"Foo\Var"')); + Inline::parse('"Foo\Var"'); } /** diff --git a/src/Symfony/Component/Yaml/Unescaper.php b/src/Symfony/Component/Yaml/Unescaper.php index 313dcf39a8a5b..996d05e376171 100644 --- a/src/Symfony/Component/Yaml/Unescaper.php +++ b/src/Symfony/Component/Yaml/Unescaper.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Yaml; +use Symfony\Component\Yaml\Exception\ParseException; + /** * Unescaper encapsulates unescaping rules for single and double-quoted * YAML strings. @@ -59,11 +61,8 @@ public function unescapeDoubleQuotedString($value) * @param string $value An escaped character * * @return string The unescaped character - * - * @internal This method is public to be usable as callback. It should not - * be used in user code. Should be changed in 3.0. */ - public function unescapeCharacter($value) + private function unescapeCharacter($value) { switch ($value[1]) { case '0': @@ -113,9 +112,7 @@ public function unescapeCharacter($value) case 'U': return self::utf8chr(hexdec(substr($value, 2, 8))); default: - @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); - - return $value; + throw new ParseException(sprintf('Found unknown escape character "%s".', $value)); } } 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