From 1ee409d002525c377e1b18ed2517b44a26cf8394 Mon Sep 17 00:00:00 2001 From: halfpastfouram Date: Fri, 31 Jul 2020 10:52:26 +0200 Subject: [PATCH] Fix broken YAML parsing Signed-off-by: halfpastfouram --- library/Zend/Config/Yaml.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/library/Zend/Config/Yaml.php b/library/Zend/Config/Yaml.php index efb805891a..f2452e1b50 100755 --- a/library/Zend/Config/Yaml.php +++ b/library/Zend/Config/Yaml.php @@ -278,6 +278,18 @@ public static function decode($yaml) return self::_decodeYaml(0, $lines); } + /** + * @param array $array + * @return array|bool + */ + protected static function _each(array &$array) + { + $key = key($array); + $current = current($array); + next($array); + return is_null($key) ? false : [$key, $current, 'key' => $key, 'value' => $current]; + } + /** * Service function to decode YAML * @@ -289,7 +301,7 @@ protected static function _decodeYaml($currentIndent, &$lines) { $config = array(); $inIndent = false; - foreach ($line as $n => $line) { + while (list($n, $line) = self::_each($lines)) { $lineno = $n + 1; $line = rtrim(preg_replace("/#.*$/", "", $line));