Skip to content

Commit

Permalink
Merge branch '2.2'
Browse files Browse the repository at this point in the history
* 2.2:
  fixed CS
  Fixed XML syntax.
  Fixed parsing of leading blank lines in folded scalars. Closes #7989.
  [Form] Fixed a method name.
  Added a test case for Loader::import().
  Fixed Loader import
  [Console] Added dedicated testcase for HelperSet class
  [Serializer] fixed CS (refs #7971)
  Fixed fatal error in normalize/denormalizeObject.
  Fixed 2 namespaces

Conflicts:
	src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php
	src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
  • Loading branch information
fabpot committed May 10, 2013
2 parents 4ae8967 + 2412f99 commit 246b254
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Parser.php
Expand Up @@ -421,18 +421,28 @@ private function parseFoldedScalar($separator, $indicator = '', $indentation = 0
return '';
}

$isCurrentLineBlank = $this->isCurrentLineBlank();
$text = '';

// leading blank lines are consumed before determining indentation
while ($notEOF && $isCurrentLineBlank) {
// newline only if not EOF
if ($notEOF = $this->moveToNextLine()) {
$text .= "\n";
$isCurrentLineBlank = $this->isCurrentLineBlank();
}
}

// determine indentation if not specified
if (0 === $indentation) {
if (preg_match('/^ +/', $this->currentLine, $matches)) {
$indentation = strlen($matches[0]);
}
}

$text = '';
if ($indentation > 0) {
$pattern = sprintf('/^ {%d}(.*)$/', $indentation);

$isCurrentLineBlank = $this->isCurrentLineBlank();
while (
$notEOF && (
$isCurrentLineBlank ||
Expand Down
21 changes: 21 additions & 0 deletions Tests/ParserTest.php
Expand Up @@ -396,6 +396,27 @@ public function testBlockChomping($expected, $yaml)
$this->assertSame($expected, $this->parser->parse($yaml));
}

/**
* Regression test for issue #7989.
*
* @see https://github.com/symfony/symfony/issues/7989
*/
public function testBlockLiteralWithLeadingNewlines()
{
$yaml = <<<'EOF'
foo: |-
bar
EOF;
$expected = array(
'foo' => "\n\nbar"
);

$this->assertSame($expected, $this->parser->parse($yaml));
}

public function testObjectSupportEnabled()
{
$input = <<<EOF
Expand Down

0 comments on commit 246b254

Please sign in to comment.