Let a partner adopt the owner's custom networks from the conf phase 1 already cached, instead of asking for a value it cannot know
This commit is contained in:
@@ -883,6 +883,30 @@ function vv_parse_conf_scalar(string $raw, string $key): string {
|
||||
return vv_conf_unquote(ltrim($m[1]));
|
||||
}
|
||||
|
||||
// Read a bash array of plain strings out of a conf, skipping commented entries.
|
||||
//
|
||||
// Distinct from vv_parse_conf_array() in scheduler.php, which looks the same but keeps only
|
||||
// entries ending in .sh — it exists to read job lists. Handing it a list of docker networks
|
||||
// returns an empty array, silently, because none of them are scripts. This one makes no
|
||||
// assumption about what the entries mean.
|
||||
//
|
||||
// The closing paren must be at the start of its own line, matching the shape conf_upgrade
|
||||
// writes and the same anchor the scheduler parser uses — a value containing ')' would
|
||||
// otherwise end the array early.
|
||||
function vv_parse_conf_list(string $raw, string $key): array {
|
||||
if (!preg_match('/^\s*' . preg_quote($key, '/') . '\s*=\s*\((.*?)^\s*\)/ms', $raw, $m)) {
|
||||
return [];
|
||||
}
|
||||
$out = [];
|
||||
foreach (explode("\n", $m[1]) as $line) {
|
||||
if (preg_match('/^\s*#/', $line)) continue; // commented-out entry
|
||||
if (!preg_match('/"([^"]*)"|\'([^\']*)\'/', $line, $e)) continue;
|
||||
$val = trim($e[1] !== '' ? $e[1] : ($e[2] ?? ''));
|
||||
if ($val !== '') $out[] = $val;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
// Unquote one bash word the way bash does, because the regexes this replaced did not and the
|
||||
// conf is read by both. Three separate regexes each handled one quoting style in isolation and
|
||||
// none of them handled an escape or two quoted runs in a row, so a value carrying a quote or a
|
||||
|
||||
Reference in New Issue
Block a user