From a76a1c9fc2ee786d81e1bd91c0773045ee20c362 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 6 Jun 2022 14:49:37 +0200 Subject: [PATCH] Fix parsing of multi-line arrays in funding yml, fixes #10784 --- src/Composer/Repository/Vcs/GitHubDriver.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 33d7e8cd3..96f7ed996 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -234,6 +234,10 @@ class GitHubDriver extends VcsDriver foreach (Preg::split('{\r?\n}', $funding) as $line) { $line = trim($line); if (Preg::isMatch('{^(\w+)\s*:\s*(.+)$}', $line, $match)) { + if ($match[2] === '[') { + $key = $match[1]; + continue; + } if (Preg::isMatch('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) { foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) { $result[] = array('type' => $match[1], 'url' => trim($item, '"\' ')); @@ -244,8 +248,13 @@ class GitHubDriver extends VcsDriver $key = null; } elseif (Preg::isMatch('{^(\w+)\s*:\s*#\s*$}', $line, $match)) { $key = $match[1]; - } elseif ($key && Preg::isMatch('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) { + } elseif ($key && ( + Preg::isMatch('{^-\s*(.+)(\s+#.*)?$}', $line, $match) + || Preg::isMatch('{^(.+),(\s*#.*)?$}', $line, $match) + )) { $result[] = array('type' => $key, 'url' => trim($match[1], '"\' ')); + } elseif ($key && $line === ']') { + $key = null; } }