Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4cba31e

Browse filesBrowse files
committed
minor #39769 [Yaml] quote all dumped unicode spaces (xabbuh)
This PR was merged into the 4.4 branch. Discussion ---------- [Yaml] quote all dumped unicode spaces | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #39767 | License | MIT | Doc PR | Commits ------- 0028efe quote all dumped unicode spaces
2 parents 3ee310f + 0028efe commit 4cba31e
Copy full SHA for 4cba31e

File tree

3 files changed

+20
-1
lines changed
Filter options

3 files changed

+20
-1
lines changed

‎src/Symfony/Component/Yaml/Escaper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Escaper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public static function requiresSingleQuoting(string $value): bool
8686

8787
// Determines if the PHP value contains any single characters that would
8888
// cause it to require single quoting in YAML.
89-
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
89+
return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` \p{Zs}]/xu', $value);
9090
}
9191

9292
/**

‎src/Symfony/Component/Yaml/Tests/DumperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/DumperTest.php
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,21 @@ public function testDumpNullAsTilde()
635635
{
636636
$this->assertSame('{ foo: ~ }', $this->dumper->dump(['foo' => null], 0, 0, Yaml::DUMP_NULL_AS_TILDE));
637637
}
638+
639+
public function testDumpIdeographicSpaces()
640+
{
641+
$expected = <<<YAML
642+
alone: ' '
643+
within_string: 'a b'
644+
regular_space: 'a b'
645+
646+
YAML;
647+
$this->assertSame($expected, $this->dumper->dump([
648+
'alone' => ' ',
649+
'within_string' => 'a b',
650+
'regular_space' => 'a b',
651+
], 2));
652+
}
638653
}
639654

640655
class A

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ public function getTestsForDump()
511511
['"0123\r"', "0123\r"],
512512
['"0123\t"', "0123\t"],
513513
['"0123\v"', "0123\v"],
514+
515+
// whitespaces
516+
'ideographic space' => ["' '", ' '],
517+
'ideographic space surrounded by characters' => ["'a b'", 'a b'],
514518
];
515519
}
516520

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.