[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
|
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]);
|
$value = Inline::load($this->lines[0]);
|
||||||
if (is_array($value))
|
if (is_array($value))
|
||||||
@ -540,8 +541,10 @@ class Parser
|
|||||||
{
|
{
|
||||||
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
$value = str_replace(array("\r\n", "\r"), "\n", $value);
|
||||||
|
|
||||||
// remove trailing newlines
|
if (!preg_match("#\n$#", $value))
|
||||||
$value = rtrim($value, "\n");
|
{
|
||||||
|
$value .= "\n";
|
||||||
|
}
|
||||||
|
|
||||||
// strip YAML header
|
// strip YAML header
|
||||||
preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);
|
preg_replace('#^\%YAML[: ][\d\.]+.*\n#s', '', $value);
|
||||||
|
@ -13,6 +13,12 @@ yaml: |
|
|||||||
php: |
|
php: |
|
||||||
array('foo' => array())
|
array('foo' => array())
|
||||||
---
|
---
|
||||||
|
test: Empty value
|
||||||
|
yaml: |
|
||||||
|
foo:
|
||||||
|
php: |
|
||||||
|
array('foo' => null)
|
||||||
|
---
|
||||||
test: Inline string parsing
|
test: Inline string parsing
|
||||||
brief: >
|
brief: >
|
||||||
Inline string parsing
|
Inline string parsing
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Components\Yaml\Dumper;
|
|||||||
|
|
||||||
Yaml::setSpecVersion('1.1');
|
Yaml::setSpecVersion('1.1');
|
||||||
|
|
||||||
$t = new LimeTest(148);
|
$t = new LimeTest(149);
|
||||||
|
|
||||||
$parser = new Parser();
|
$parser = new Parser();
|
||||||
$dumper = new Dumper();
|
$dumper = new Dumper();
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Components\Yaml\ParserException;
|
|||||||
|
|
||||||
Yaml::setSpecVersion('1.1');
|
Yaml::setSpecVersion('1.1');
|
||||||
|
|
||||||
$t = new LimeTest(148);
|
$t = new LimeTest(149);
|
||||||
|
|
||||||
$parser = new Parser();
|
$parser = new Parser();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user