Skip to content

Commit 3b28bcb

Browse files
matej21dg
authored andcommitted
Decoder: array-after-key syntax allows only array, not scalars [BC break]
1 parent 74e1bbe commit 3b28bcb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Neon/Decoder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ private function parse($indent, $result = NULL, $key = NULL, $hasKey = FALSE)
219219

220220
} elseif ($hasKey) {
221221
$this->addValue($result, $key !== NULL, $key, $hasValue ? $value : NULL);
222-
if ($key !== NULL && !$hasValue && $newIndent === $indent) {
222+
if ($key !== NULL && !$hasValue && $newIndent === $indent && isset($tokens[$n + 1]) && $tokens[$n + 1][0] === '-') {
223223
$result = & $result[$key];
224224
}
225225
$hasKey = $hasValue = FALSE;

tests/Neon/Decoder.errors.phpt

+8
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,11 @@ Assert::exception(function() {
9090
Assert::exception(function() {
9191
Neon::decode('- x: y:');
9292
}, 'Nette\Neon\Exception', "Unexpected ':' on line 1, column 7." );
93+
94+
95+
Assert::exception(function () {
96+
Neon::decode('
97+
foo:
98+
bar
99+
');
100+
}, 'Nette\Neon\Exception', "Unexpected '<new line>' on line 3, column 4.");

0 commit comments

Comments
 (0)