Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a76a1c9

Browse files
committed
Fix parsing of multi-line arrays in funding yml, fixes #10784
1 parent 1e9210f commit a76a1c9

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Composer/Repository/Vcs/GitHubDriver.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ private function getFundingInfo()
234234
foreach (Preg::split('{\r?\n}', $funding) as $line) {
235235
$line = trim($line);
236236
if (Preg::isMatch('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
237+
if ($match[2] === '[') {
238+
$key = $match[1];
239+
continue;
240+
}
237241
if (Preg::isMatch('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
238242
foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
239243
$result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
@@ -244,8 +248,13 @@ private function getFundingInfo()
244248
$key = null;
245249
} elseif (Preg::isMatch('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
246250
$key = $match[1];
247-
} elseif ($key && Preg::isMatch('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
251+
} elseif ($key && (
252+
Preg::isMatch('{^-\s*(.+)(\s+#.*)?$}', $line, $match)
253+
|| Preg::isMatch('{^(.+),(\s*#.*)?$}', $line, $match)
254+
)) {
248255
$result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
256+
} elseif ($key && $line === ']') {
257+
$key = null;
249258
}
250259
}
251260

0 commit comments

Comments
 (0)