update v1.0.4
This commit is contained in:
26
vendor/symfony/yaml/CHANGELOG.md
vendored
26
vendor/symfony/yaml/CHANGELOG.md
vendored
@@ -1,6 +1,32 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
* Yaml::parse() now throws an exception when a blackslash is not escaped
|
||||
in double-quoted strings
|
||||
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
* Deprecated usage of a colon in an unquoted mapping value
|
||||
* Deprecated usage of @, \`, | and > at the beginning of an unquoted string
|
||||
* When surrounding strings with double-quotes, you must now escape `\` characters. Not
|
||||
escaping those characters (when surrounded by double-quotes) is deprecated.
|
||||
|
||||
Before:
|
||||
|
||||
```yml
|
||||
class: "Foo\Var"
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```yml
|
||||
class: "Foo\\Var"
|
||||
```
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
|
2
vendor/symfony/yaml/Escaper.php
vendored
2
vendor/symfony/yaml/Escaper.php
vendored
@@ -16,6 +16,8 @@ namespace Symfony\Component\Yaml;
|
||||
* YAML strings.
|
||||
*
|
||||
* @author Matthew Lewinski <matthew@lewinski.org>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Escaper
|
||||
{
|
||||
|
@@ -123,12 +123,7 @@ class ParseException extends RuntimeException
|
||||
}
|
||||
|
||||
if (null !== $this->parsedFile) {
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$jsonOptions = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
|
||||
} else {
|
||||
$jsonOptions = 0;
|
||||
}
|
||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, $jsonOptions));
|
||||
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
if ($this->parsedLine >= 0) {
|
||||
|
9
vendor/symfony/yaml/Inline.php
vendored
9
vendor/symfony/yaml/Inline.php
vendored
@@ -52,7 +52,7 @@ class Inline
|
||||
return '';
|
||||
}
|
||||
|
||||
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
||||
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('ASCII');
|
||||
}
|
||||
@@ -204,6 +204,8 @@ class Inline
|
||||
* @return string A YAML string
|
||||
*
|
||||
* @throws ParseException When malformed inline YAML string is parsed
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array('"', "'"), &$i = 0, $evaluate = true, $references = array())
|
||||
{
|
||||
@@ -234,6 +236,11 @@ class Inline
|
||||
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
|
||||
}
|
||||
|
||||
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
|
||||
if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) {
|
||||
throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]));
|
||||
}
|
||||
|
||||
if ($evaluate) {
|
||||
$output = self::evaluateScalar($output, $references);
|
||||
}
|
||||
|
113
vendor/symfony/yaml/Parser.php
vendored
113
vendor/symfony/yaml/Parser.php
vendored
@@ -21,8 +21,6 @@ use Symfony\Component\Yaml\Exception\ParseException;
|
||||
class Parser
|
||||
{
|
||||
const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
|
||||
// BC - wrongly named
|
||||
const FOLDED_SCALAR_PATTERN = self::BLOCK_SCALAR_HEADER_PATTERN;
|
||||
|
||||
private $offset = 0;
|
||||
private $lines = array();
|
||||
@@ -62,7 +60,7 @@ class Parser
|
||||
$value = $this->cleanup($value);
|
||||
$this->lines = explode("\n", $value);
|
||||
|
||||
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
|
||||
if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
|
||||
$mbEncoding = mb_internal_encoding();
|
||||
mb_internal_encoding('UTF-8');
|
||||
}
|
||||
@@ -114,7 +112,7 @@ class Parser
|
||||
|
||||
$data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
} else {
|
||||
$data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
$data[] = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap, $context);
|
||||
}
|
||||
}
|
||||
if ($isRef) {
|
||||
@@ -230,7 +228,7 @@ class Parser
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
$value = $this->parseValue($values['value'], $exceptionOnInvalidType, $objectSupport, $objectForMap, $context);
|
||||
// Spec: Keys MUST be unique; first one wins.
|
||||
// But overwriting is allowed when a merge node is used in current block.
|
||||
if ($allowOverwrite || !isset($data[$key])) {
|
||||
@@ -240,6 +238,10 @@ class Parser
|
||||
if ($isRef) {
|
||||
$this->refs[$isRef] = $data[$key];
|
||||
}
|
||||
|
||||
if ($objectForMap && !is_object($data)) {
|
||||
$data = (object) $data;
|
||||
}
|
||||
} else {
|
||||
// multiple documents are not supported
|
||||
if ('---' === $this->currentLine) {
|
||||
@@ -339,6 +341,7 @@ class Parser
|
||||
private function getNextEmbedBlock($indentation = null, $inSequence = false)
|
||||
{
|
||||
$oldLineIndentation = $this->getCurrentLineIndentation();
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
|
||||
if (!$this->moveToNextLine()) {
|
||||
return;
|
||||
@@ -347,7 +350,7 @@ class Parser
|
||||
if (null === $indentation) {
|
||||
$newIndent = $this->getCurrentLineIndentation();
|
||||
|
||||
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
||||
$unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
|
||||
|
||||
if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
|
||||
throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine);
|
||||
@@ -373,20 +376,24 @@ class Parser
|
||||
return;
|
||||
}
|
||||
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
|
||||
|
||||
// Comments must not be removed inside a block scalar
|
||||
$removeCommentsPattern = '~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~';
|
||||
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
|
||||
if (!$insideBlockScalar) {
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
}
|
||||
|
||||
$previousLineIndentation = $this->getCurrentLineIndentation();
|
||||
|
||||
while ($this->moveToNextLine()) {
|
||||
$indent = $this->getCurrentLineIndentation();
|
||||
|
||||
if ($indent === $newIndent) {
|
||||
$removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
|
||||
if (!$insideBlockScalar && $indent === $previousLineIndentation) {
|
||||
$insideBlockScalar = $this->isBlockScalarHeader();
|
||||
}
|
||||
|
||||
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) {
|
||||
$previousLineIndentation = $indent;
|
||||
|
||||
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
|
||||
$this->moveToPreviousLine();
|
||||
break;
|
||||
}
|
||||
@@ -396,7 +403,8 @@ class Parser
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($removeComments && $this->isCurrentLineComment()) {
|
||||
// we ignore "comment" lines only when we are not inside a scalar block
|
||||
if (!$insideBlockScalar && $this->isCurrentLineComment()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -445,12 +453,13 @@ class Parser
|
||||
* @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
|
||||
* @param bool $objectSupport True if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap true if maps should return a stdClass instead of array()
|
||||
* @param string $context The parser context (either sequence or mapping)
|
||||
*
|
||||
* @return mixed A PHP value
|
||||
*
|
||||
* @throws ParseException When reference does not exist
|
||||
*/
|
||||
private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $objectForMap)
|
||||
private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $context)
|
||||
{
|
||||
if (0 === strpos($value, '*')) {
|
||||
if (false !== $pos = strpos($value, '#')) {
|
||||
@@ -473,7 +482,13 @@ class Parser
|
||||
}
|
||||
|
||||
try {
|
||||
return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
|
||||
$parsedValue = Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
|
||||
|
||||
if ('mapping' === $context && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
|
||||
throw new ParseException('A colon cannot be used in an unquoted mapping value.');
|
||||
}
|
||||
|
||||
return $parsedValue;
|
||||
} catch (ParseException $e) {
|
||||
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
|
||||
$e->setSnippet($this->currentLine);
|
||||
@@ -499,13 +514,13 @@ class Parser
|
||||
}
|
||||
|
||||
$isCurrentLineBlank = $this->isCurrentLineBlank();
|
||||
$text = '';
|
||||
$blockLines = array();
|
||||
|
||||
// leading blank lines are consumed before determining indentation
|
||||
while ($notEOF && $isCurrentLineBlank) {
|
||||
// newline only if not EOF
|
||||
if ($notEOF = $this->moveToNextLine()) {
|
||||
$text .= "\n";
|
||||
$blockLines[] = '';
|
||||
$isCurrentLineBlank = $this->isCurrentLineBlank();
|
||||
}
|
||||
}
|
||||
@@ -526,37 +541,59 @@ class Parser
|
||||
preg_match($pattern, $this->currentLine, $matches)
|
||||
)
|
||||
) {
|
||||
if ($isCurrentLineBlank) {
|
||||
$text .= substr($this->currentLine, $indentation);
|
||||
if ($isCurrentLineBlank && strlen($this->currentLine) > $indentation) {
|
||||
$blockLines[] = substr($this->currentLine, $indentation);
|
||||
} elseif ($isCurrentLineBlank) {
|
||||
$blockLines[] = '';
|
||||
} else {
|
||||
$text .= $matches[1];
|
||||
$blockLines[] = $matches[1];
|
||||
}
|
||||
|
||||
// newline only if not EOF
|
||||
if ($notEOF = $this->moveToNextLine()) {
|
||||
$text .= "\n";
|
||||
$isCurrentLineBlank = $this->isCurrentLineBlank();
|
||||
}
|
||||
}
|
||||
} elseif ($notEOF) {
|
||||
$text .= "\n";
|
||||
$blockLines[] = '';
|
||||
}
|
||||
|
||||
if ($notEOF) {
|
||||
$blockLines[] = '';
|
||||
$this->moveToPreviousLine();
|
||||
}
|
||||
|
||||
// folded style
|
||||
if ('>' === $style) {
|
||||
// folded lines
|
||||
// replace all non-leading/non-trailing single newlines with spaces
|
||||
preg_match('/(\n*)$/', $text, $matches);
|
||||
$text = preg_replace('/(?<!\n|^)\n(?!\n)/', ' ', rtrim($text, "\n"));
|
||||
$text .= $matches[1];
|
||||
$text = '';
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
|
||||
// empty separation lines
|
||||
// remove one newline from each group of non-leading/non-trailing newlines
|
||||
$text = preg_replace('/[^\n]\n+\K\n(?=[^\n])/', '', $text);
|
||||
for ($i = 0; $i < count($blockLines); $i++) {
|
||||
if ('' === $blockLines[$i]) {
|
||||
$text .= "\n";
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = true;
|
||||
} elseif (' ' === $blockLines[$i][0]) {
|
||||
$text .= "\n".$blockLines[$i];
|
||||
$previousLineIndented = true;
|
||||
$previousLineBlank = false;
|
||||
} elseif ($previousLineIndented) {
|
||||
$text .= "\n".$blockLines[$i];
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
} elseif ($previousLineBlank || 0 === $i) {
|
||||
$text .= $blockLines[$i];
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
} else {
|
||||
$text .= ' '.$blockLines[$i];
|
||||
$previousLineIndented = false;
|
||||
$previousLineBlank = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$text = implode("\n", $blockLines);
|
||||
}
|
||||
|
||||
// deal with trailing newlines
|
||||
@@ -690,7 +727,7 @@ class Parser
|
||||
if (
|
||||
$this->getCurrentLineIndentation() == $currentIndentation
|
||||
&&
|
||||
$this->isStringUnIndentedCollectionItem($this->currentLine)
|
||||
$this->isStringUnIndentedCollectionItem()
|
||||
) {
|
||||
$ret = true;
|
||||
}
|
||||
@@ -707,6 +744,16 @@ class Parser
|
||||
*/
|
||||
private function isStringUnIndentedCollectionItem()
|
||||
{
|
||||
return (0 === strpos($this->currentLine, '- '));
|
||||
return 0 === strpos($this->currentLine, '- ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether or not the current line is the header of a block scalar.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isBlockScalarHeader()
|
||||
{
|
||||
return (bool) preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine);
|
||||
}
|
||||
}
|
||||
|
@@ -145,3 +145,11 @@ php: |
|
||||
array(
|
||||
'double' => "some value\n \"some quoted string\" and 'some single quotes one'"
|
||||
)
|
||||
---
|
||||
test: Backslashes
|
||||
yaml: |
|
||||
{ single: 'foo\Var', no-quotes: foo\Var, double: "foo\\Var" }
|
||||
php: |
|
||||
array(
|
||||
'single' => 'foo\Var', 'no-quotes' => 'foo\Var', 'double' => 'foo\Var'
|
||||
)
|
||||
|
@@ -3,7 +3,7 @@ test: Some characters at the beginning of a string must be escaped
|
||||
brief: >
|
||||
Some characters at the beginning of a string must be escaped
|
||||
yaml: |
|
||||
foo: | bar
|
||||
foo: '| bar'
|
||||
php: |
|
||||
array('foo' => '| bar')
|
||||
---
|
||||
|
51
vendor/symfony/yaml/Tests/InlineTest.php
vendored
51
vendor/symfony/yaml/Tests/InlineTest.php
vendored
@@ -58,10 +58,8 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertEquals('1.2', Inline::dump(1.2));
|
||||
$this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
|
||||
} finally {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
} catch (\Exception $e) {
|
||||
setlocale(LC_NUMERIC, $locale);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +70,23 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($value, Inline::parse(Inline::dump($value)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage Found unknown escape character "\V".
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\Var"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
|
||||
{
|
||||
Inline::parse('"Foo\\"');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
@@ -173,6 +188,36 @@ class InlineTest extends \PHPUnit_Framework_TestCase
|
||||
Inline::parse('{ foo: * #foo }');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getReservedIndicators
|
||||
* @expectedException Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
|
||||
{
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getReservedIndicators()
|
||||
{
|
||||
return array(array('@'), array('`'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getScalarIndicators
|
||||
* @expectedException Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage cannot start a plain scalar; you need to quote the scalar.
|
||||
*/
|
||||
public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
|
||||
{
|
||||
Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
|
||||
}
|
||||
|
||||
public function getScalarIndicators()
|
||||
{
|
||||
return array(array('|'), array('>'));
|
||||
}
|
||||
|
||||
public function getTestsForParse()
|
||||
{
|
||||
return array(
|
||||
|
12
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
12
vendor/symfony/yaml/Tests/ParseExceptionTest.php
vendored
@@ -18,11 +18,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetMessage()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||
} else {
|
||||
$message = 'Error message in "\\/var\\/www\\/app\\/config.yml" at line 42 (near "foo: bar")';
|
||||
}
|
||||
$message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
@@ -30,11 +26,7 @@ class ParseExceptionTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetMessageWithUnicodeInFilename()
|
||||
{
|
||||
$exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
|
||||
if (PHP_VERSION_ID >= 50400) {
|
||||
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||
} else {
|
||||
$message = 'Error message in "\u00e4\u00f6\u00fc.yml" at line 42 (near "foo: bar")';
|
||||
}
|
||||
$message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
|
||||
|
||||
$this->assertEquals($message, $exception->getMessage());
|
||||
}
|
||||
|
195
vendor/symfony/yaml/Tests/ParserTest.php
vendored
195
vendor/symfony/yaml/Tests/ParserTest.php
vendored
@@ -438,6 +438,28 @@ EOF;
|
||||
$this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
|
||||
}
|
||||
|
||||
public function testObjectForMapEnabledWithMapping()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
foo:
|
||||
fiz: [cat]
|
||||
EOF;
|
||||
$result = $this->parser->parse($yaml, false, false, true);
|
||||
|
||||
$this->assertInstanceOf('stdClass', $result);
|
||||
$this->assertInstanceOf('stdClass', $result->foo);
|
||||
$this->assertEquals(array('cat'), $result->foo->fiz);
|
||||
}
|
||||
|
||||
public function testObjectForMapEnabledWithInlineMapping()
|
||||
{
|
||||
$result = $this->parser->parse('{ "foo": "bar", "fiz": "cat" }', false, false, true);
|
||||
|
||||
$this->assertInstanceOf('stdClass', $result);
|
||||
$this->assertEquals('bar', $result->foo);
|
||||
$this->assertEquals('cat', $result->fiz);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
*/
|
||||
@@ -572,8 +594,6 @@ EOF
|
||||
*
|
||||
* @see http://yaml.org/spec/1.2/spec.html#id2759572
|
||||
* @see http://yaml.org/spec/1.1/#id932806
|
||||
*
|
||||
* @covers \Symfony\Component\Yaml\Parser::parse
|
||||
*/
|
||||
public function testMappingDuplicateKeyBlock()
|
||||
{
|
||||
@@ -593,9 +613,6 @@ EOD;
|
||||
$this->assertSame($expected, Yaml::parse($input));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Symfony\Component\Yaml\Inline::parseMapping
|
||||
*/
|
||||
public function testMappingDuplicateKeyFlow()
|
||||
{
|
||||
$input = <<<EOD
|
||||
@@ -788,6 +805,174 @@ EOF;
|
||||
|
||||
$this->assertEquals($expected, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
|
||||
* @expectedExceptionMessage A colon cannot be used in an unquoted mapping value
|
||||
*/
|
||||
public function testColonInMappingValueException()
|
||||
{
|
||||
$yaml = <<<EOF
|
||||
foo: bar: baz
|
||||
EOF;
|
||||
|
||||
$this->parser->parse($yaml);
|
||||
}
|
||||
|
||||
public function testColonInMappingValueExceptionNotTriggeredByColonInComment()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
foo:
|
||||
bar: foobar # Note: a comment after a colon
|
||||
EOT;
|
||||
|
||||
$this->assertSame(array('foo' => array('bar' => 'foobar')), $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getCommentLikeStringInScalarBlockData
|
||||
*/
|
||||
public function testCommentLikeStringsAreNotStrippedInBlockScalars($yaml, $expectedParserResult)
|
||||
{
|
||||
$this->assertSame($expectedParserResult, $this->parser->parse($yaml));
|
||||
}
|
||||
|
||||
public function getCommentLikeStringInScalarBlockData()
|
||||
{
|
||||
$yaml1 = <<<EOT
|
||||
pages:
|
||||
-
|
||||
title: some title
|
||||
content: |
|
||||
# comment 1
|
||||
header
|
||||
|
||||
# comment 2
|
||||
<body>
|
||||
<h1>title</h1>
|
||||
</body>
|
||||
|
||||
footer # comment3
|
||||
EOT;
|
||||
$expected1 = array(
|
||||
'pages' => array(
|
||||
array(
|
||||
'title' => 'some title',
|
||||
'content' => <<<EOT
|
||||
# comment 1
|
||||
header
|
||||
|
||||
# comment 2
|
||||
<body>
|
||||
<h1>title</h1>
|
||||
</body>
|
||||
|
||||
footer # comment3
|
||||
EOT
|
||||
,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$yaml2 = <<<EOT
|
||||
test: |
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
collection:
|
||||
- one: |
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
- two: |
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
EOT;
|
||||
$expected2 = array(
|
||||
'test' => <<<EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
|
||||
EOT
|
||||
,
|
||||
'collection' => array(
|
||||
array(
|
||||
'one' => <<<EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
EOT
|
||||
,
|
||||
),
|
||||
array(
|
||||
'two' => <<<EOT
|
||||
foo
|
||||
# bar
|
||||
baz
|
||||
EOT
|
||||
,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
return array(
|
||||
array($yaml1, $expected1),
|
||||
array($yaml2, $expected2),
|
||||
);
|
||||
}
|
||||
|
||||
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
test: >
|
||||
<h2>A heading</h2>
|
||||
|
||||
<ul>
|
||||
<li>a list</li>
|
||||
<li>may be a good example</li>
|
||||
</ul>
|
||||
EOT;
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'test' => <<<EOT
|
||||
<h2>A heading</h2>
|
||||
<ul> <li>a list</li> <li>may be a good example</li> </ul>
|
||||
EOT
|
||||
,
|
||||
),
|
||||
$this->parser->parse($yaml)
|
||||
);
|
||||
}
|
||||
|
||||
public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks()
|
||||
{
|
||||
$yaml = <<<EOT
|
||||
test: >
|
||||
<h2>A heading</h2>
|
||||
|
||||
<ul>
|
||||
<li>a list</li>
|
||||
<li>may be a good example</li>
|
||||
</ul>
|
||||
EOT;
|
||||
|
||||
$this->assertSame(
|
||||
array(
|
||||
'test' => <<<EOT
|
||||
<h2>A heading</h2>
|
||||
<ul>
|
||||
<li>a list</li>
|
||||
<li>may be a good example</li>
|
||||
</ul>
|
||||
EOT
|
||||
,
|
||||
),
|
||||
$this->parser->parse($yaml)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class B
|
||||
|
12
vendor/symfony/yaml/Tests/YamlTest.php
vendored
12
vendor/symfony/yaml/Tests/YamlTest.php
vendored
@@ -22,16 +22,4 @@ class YamlTest extends \PHPUnit_Framework_TestCase
|
||||
$parsed = Yaml::parse($yml);
|
||||
$this->assertEquals($data, $parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
public function testLegacyParseFromFile()
|
||||
{
|
||||
$filename = __DIR__.'/Fixtures/index.yml';
|
||||
$contents = file_get_contents($filename);
|
||||
$parsedByFilename = Yaml::parse($filename);
|
||||
$parsedByContents = Yaml::parse($contents);
|
||||
$this->assertEquals($parsedByFilename, $parsedByContents);
|
||||
}
|
||||
}
|
||||
|
27
vendor/symfony/yaml/Unescaper.php
vendored
27
vendor/symfony/yaml/Unescaper.php
vendored
@@ -11,28 +11,22 @@
|
||||
|
||||
namespace Symfony\Component\Yaml;
|
||||
|
||||
use Symfony\Component\Yaml\Exception\ParseException;
|
||||
|
||||
/**
|
||||
* Unescaper encapsulates unescaping rules for single and double-quoted
|
||||
* YAML strings.
|
||||
*
|
||||
* @author Matthew Lewinski <matthew@lewinski.org>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Unescaper
|
||||
{
|
||||
/**
|
||||
* Parser and Inline assume UTF-8 encoding, so escaped Unicode characters
|
||||
* must be converted to that encoding.
|
||||
*
|
||||
* @deprecated since version 2.5, to be removed in 3.0
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
const ENCODING = 'UTF-8';
|
||||
|
||||
/**
|
||||
* Regex fragment that matches an escaped character in a double quoted string.
|
||||
*/
|
||||
const REGEX_ESCAPED_CHARACTER = "\\\\([0abt\tnvfre \\\"\\/\\\\N_LP]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})";
|
||||
const REGEX_ESCAPED_CHARACTER = "\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)";
|
||||
|
||||
/**
|
||||
* Unescapes a single quoted string.
|
||||
@@ -55,9 +49,8 @@ class Unescaper
|
||||
*/
|
||||
public function unescapeDoubleQuotedString($value)
|
||||
{
|
||||
$self = $this;
|
||||
$callback = function ($match) use ($self) {
|
||||
return $self->unescapeCharacter($match[0]);
|
||||
$callback = function ($match) {
|
||||
return $this->unescapeCharacter($match[0]);
|
||||
};
|
||||
|
||||
// evaluate the string
|
||||
@@ -71,9 +64,9 @@ class Unescaper
|
||||
*
|
||||
* @return string The unescaped character
|
||||
*/
|
||||
public function unescapeCharacter($value)
|
||||
private function unescapeCharacter($value)
|
||||
{
|
||||
switch ($value{1}) {
|
||||
switch ($value[1]) {
|
||||
case '0':
|
||||
return "\x0";
|
||||
case 'a':
|
||||
@@ -120,6 +113,8 @@ class Unescaper
|
||||
return self::utf8chr(hexdec(substr($value, 2, 4)));
|
||||
case 'U':
|
||||
return self::utf8chr(hexdec(substr($value, 2, 8)));
|
||||
default:
|
||||
throw new ParseException(sprintf('Found unknown escape character "%s".', $value));
|
||||
}
|
||||
}
|
||||
|
||||
|
31
vendor/symfony/yaml/Yaml.php
vendored
31
vendor/symfony/yaml/Yaml.php
vendored
@@ -32,13 +32,7 @@ class Yaml
|
||||
* print_r($array);
|
||||
* </code>
|
||||
*
|
||||
* As this method accepts both plain strings and file names as an input,
|
||||
* you must validate the input before calling this method. Passing a file
|
||||
* as an input is a deprecated feature and will be removed in 3.0.
|
||||
*
|
||||
* Note: the ability to pass file names to the Yaml::parse method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.
|
||||
*
|
||||
* @param string $input Path to a YAML file or a string containing YAML
|
||||
* @param string $input A string containing YAML
|
||||
* @param bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
|
||||
* @param bool $objectSupport True if object support is enabled, false otherwise
|
||||
* @param bool $objectForMap True if maps should return a stdClass instead of array()
|
||||
@@ -49,30 +43,9 @@ class Yaml
|
||||
*/
|
||||
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false)
|
||||
{
|
||||
// if input is a file, process it
|
||||
$file = '';
|
||||
if (strpos($input, "\n") === false && is_file($input)) {
|
||||
@trigger_error('The ability to pass file names to the '.__METHOD__.' method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.', E_USER_DEPRECATED);
|
||||
|
||||
if (false === is_readable($input)) {
|
||||
throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
|
||||
}
|
||||
|
||||
$file = $input;
|
||||
$input = file_get_contents($file);
|
||||
}
|
||||
|
||||
$yaml = new Parser();
|
||||
|
||||
try {
|
||||
return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
} catch (ParseException $e) {
|
||||
if ($file) {
|
||||
$e->setParsedFile($file);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport, $objectForMap);
|
||||
}
|
||||
|
||||
/**
|
||||
|
9
vendor/symfony/yaml/composer.json
vendored
9
vendor/symfony/yaml/composer.json
vendored
@@ -16,15 +16,18 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.9"
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Yaml\\": "" }
|
||||
"psr-4": { "Symfony\\Component\\Yaml\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.7-dev"
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
vendor/symfony/yaml/phpunit.xml.dist
vendored
2
vendor/symfony/yaml/phpunit.xml.dist
vendored
@@ -20,8 +20,8 @@
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./vendor</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
Reference in New Issue
Block a user