Skip to content

Commit

Permalink
[Yaml] fixed parsing of simple inline documents
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 29, 2010
1 parent 97cafc7 commit 6e18a2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -80,7 +80,7 @@ public function parse($value)
} else {
if (isset($values['leadspaces'])
&& ' ' == $values['leadspaces']
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
) {
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
Expand All @@ -97,7 +97,7 @@ public function parse($value)
$data[] = $this->parseValue($values['value']);
}
}
} else if (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
} else if (preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\[\{].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->currentLine, $values)) {
$key = Inline::parseScalar($values['key']);

if ('<<' === $key) {
Expand Down
14 changes: 14 additions & 0 deletions tests/Symfony/Tests/Component/Yaml/Fixtures/sfTests.yml
Expand Up @@ -143,3 +143,17 @@ yaml: |
0123
php: |
array('foo' => "0123\n")
---
test: Document as a simple hash
brief: Document as a simple hash
yaml: |
{ foo: bar }
php: |
array('foo' => 'bar')
---
test: Document as a simple array
brief: Document as a simple array
yaml: |
[ foo, bar ]
php: |
array('foo', 'bar')

0 comments on commit 6e18a2c

Please sign in to comment.