1
0
Fork 0

Fix parsing of multi-line arrays in funding yml, fixes #10784

pull/10823/head
Jordi Boggiano 2022-06-06 14:49:37 +02:00
parent 1e9210f7b1
commit a76a1c9fc2
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 10 additions and 1 deletions

View File

@ -234,6 +234,10 @@ class GitHubDriver extends VcsDriver
foreach (Preg::split('{\r?\n}', $funding) as $line) { foreach (Preg::split('{\r?\n}', $funding) as $line) {
$line = trim($line); $line = trim($line);
if (Preg::isMatch('{^(\w+)\s*:\s*(.+)$}', $line, $match)) { if (Preg::isMatch('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
if ($match[2] === '[') {
$key = $match[1];
continue;
}
if (Preg::isMatch('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) { if (Preg::isMatch('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) { foreach (array_map('trim', Preg::split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
$result[] = array('type' => $match[1], 'url' => trim($item, '"\' ')); $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
@ -244,8 +248,13 @@ class GitHubDriver extends VcsDriver
$key = null; $key = null;
} elseif (Preg::isMatch('{^(\w+)\s*:\s*#\s*$}', $line, $match)) { } elseif (Preg::isMatch('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
$key = $match[1]; $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], '"\' ')); $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
} elseif ($key && $line === ']') {
$key = null;
} }
} }