quote all dumped unicode spaces
This commit is contained in:
parent
3ee310f20a
commit
0028efe8f8
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -635,6 +635,21 @@ YAML;
|
||||
{
|
||||
$this->assertSame('{ foo: ~ }', $this->dumper->dump(['foo' => null], 0, 0, Yaml::DUMP_NULL_AS_TILDE));
|
||||
}
|
||||
|
||||
public function testDumpIdeographicSpaces()
|
||||
{
|
||||
$expected = <<<YAML
|
||||
alone: ' '
|
||||
within_string: 'a b'
|
||||
regular_space: 'a b'
|
||||
|
||||
YAML;
|
||||
$this->assertSame($expected, $this->dumper->dump([
|
||||
'alone' => ' ',
|
||||
'within_string' => 'a b',
|
||||
'regular_space' => 'a b',
|
||||
], 2));
|
||||
}
|
||||
}
|
||||
|
||||
class A
|
||||
|
@ -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'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user