[Yaml] restored old behaviour of including a trailing newline during parsing. Added test case for empty value
This commit is contained in:
parent
f87f890b7a
commit
4e0204dfd5
|
@ -189,7 +189,8 @@ class Parser
|
|||
}
|
||||
else
|
||||
{
|
||||
if (1 == count($this->lines))
|
||||
// 1-liner followed by newline
|
||||
if (2 == count($this->lines) && empty($this->lines[1]))
|
||||
{
|
||||
$value = Inline::load($this->lines[0]);
|
||||
if (is_array($value))
|
||||
|
@ -540,8 +541,10 @@ class Parser
|
|||
{
|
||||
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
||||
|
||||
// remove trailing newlines
|
||||
$value = rtrim($value, "\n");
|
||||
if (!preg_match("#\n$#", $value))
|
||||
{
|
||||
$value .= "\n";
|
||||
}
|
||||
|
||||
// strip YAML header
|
||||
preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);
|
||||
|
|
|
@ -13,6 +13,12 @@ yaml: |
|
|||
php: |
|
||||
array('foo' => array())
|
||||
---
|
||||
test: Empty value
|
||||
yaml: |
|
||||
foo:
|
||||
php: |
|
||||
array('foo' => null)
|
||||
---
|
||||
test: Inline string parsing
|
||||
brief: >
|
||||
Inline string parsing
|
||||
|
|
|
@ -16,7 +16,7 @@ use Symfony\Components\Yaml\Dumper;
|
|||
|
||||
Yaml::setSpecVersion('1.1');
|
||||
|
||||
$t = new LimeTest(148);
|
||||
$t = new LimeTest(149);
|
||||
|
||||
$parser = new Parser();
|
||||
$dumper = new Dumper();
|
||||
|
|
|
@ -16,7 +16,7 @@ use Symfony\Components\Yaml\ParserException;
|
|||
|
||||
Yaml::setSpecVersion('1.1');
|
||||
|
||||
$t = new LimeTest(148);
|
||||
$t = new LimeTest(149);
|
||||
|
||||
$parser = new Parser();
|
||||
|
||||
|
|
Reference in New Issue