10000 [Yaml] Fixed the escaping of strings starting with a dash when dumping by stof · Pull Request #9274 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Yaml] Fixed the escaping of strings starting with a dash when dumping #9274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function escapeWithDoubleQuotes($value)
*/
public static function requiresSingleQuoting($value)
{
return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ - ? | < > = ! % @ ` ]/x', $value);
return preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/Symfony/Component/Yaml/Tests/InlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Symfony\Component\Yaml\Tests;

use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Inline;

class InlineTest extends \PHPUnit_Framework_TestCase
Expand All @@ -31,11 +30,11 @@ public function testDump()
$this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
}

foreach ($this->getTestsForParse() as $yaml => $value) {
foreach ($this->getTestsForParse() as $value) {
$this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency');
}

foreach ($testsForDump as $yaml => $value) {
foreach ($testsForDump as $value) {
$this->assertEquals($value, Inline::parse(Inline::dump($value)), 'check consistency');
}
}
Expand Down Expand Up @@ -205,6 +204,9 @@ protected function getTestsForDump()

"'a \"string\" with ''quoted strings inside'''" => 'a "string" with \'quoted strings inside\'',

"'-dash'" => '-dash',
"'-'" => '-',

// sequences
'[foo, bar, false, null, 12]' => array('foo', 'bar', false, null, 12),
'[\'foo,bar\', \'foo bar\']' => array('foo,bar', 'foo bar'),
Expand Down
0