diff --git a/src/Symfony/Component/Yaml/Escaper.php b/src/Symfony/Component/Yaml/Escaper.php index 150c5f6dad..78d93ddfe3 100644 --- a/src/Symfony/Component/Yaml/Escaper.php +++ b/src/Symfony/Component/Yaml/Escaper.php @@ -86,7 +86,7 @@ class Escaper // Determines if the PHP value contains any single characters that would // cause it to require single quoting in YAML. - return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value); + return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` \p{Zs}]/xu', $value); } /** diff --git a/src/Symfony/Component/Yaml/Tests/DumperTest.php b/src/Symfony/Component/Yaml/Tests/DumperTest.php index 5bf0530220..41c8b02c7b 100644 --- a/src/Symfony/Component/Yaml/Tests/DumperTest.php +++ b/src/Symfony/Component/Yaml/Tests/DumperTest.php @@ -635,6 +635,21 @@ YAML; { $this->assertSame('{ foo: ~ }', $this->dumper->dump(['foo' => null], 0, 0, Yaml::DUMP_NULL_AS_TILDE)); } + + public function testDumpIdeographicSpaces() + { + $expected = <<assertSame($expected, $this->dumper->dump([ + 'alone' => ' ', + 'within_string' => 'a b', + 'regular_space' => 'a b', + ], 2)); + } } class A diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index b4143b9c17..0f608c330c 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -511,6 +511,10 @@ class InlineTest extends TestCase ['"0123\r"', "0123\r"], ['"0123\t"', "0123\t"], ['"0123\v"', "0123\v"], + + // whitespaces + 'ideographic space' => ["' '", ' '], + 'ideographic space surrounded by characters' => ["'a b'", 'a b'], ]; }