Skip to content

Commit 8461490

Browse files
committed
simplify settings2params
using GitHub CI to test it on Windows for me..
1 parent 2684091 commit 8461490

File tree

1 file changed

+12
-25
lines changed

1 file changed

+12
-25
lines changed

run-tests.php

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,36 +2970,23 @@ function settings2array(array $settings, &$ini_settings): void
29702970
function settings2params(array $ini_settings): string
29712971
{
29722972
$settings = '';
2973-
2973+
$deep = null;
29742974
foreach ($ini_settings as $name => $value) {
2975-
if (IS_WINDOWS) {
2976-
if (is_array($value)) {
2977-
foreach ($value as $val) {
2978-
$val = addslashes($val);
2979-
$settings .= " -d \"$name=$val\"";
2980-
}
2981-
} else {
2982-
if (!empty($value) && $value[0] == '"') {
2983-
$len = strlen($value);
2984-
2985-
if ($value[$len - 1] == '"') {
2986-
$value[0] = "'";
2987-
$value[$len - 1] = "'";
2988-
}
2989-
} else {
2990-
$value = addslashes($value);
2991-
}
2992-
2993-
$settings .= " -d \"$name=$value\"";
2994-
}
2975+
if (is_array($value)) {
2976+
$deep = true;
29952977
} else {
2996-
// !IS_WINDOWS
2997-
foreach ((is_array($value) ? $value : [$value]) as $val) {
2998-
$settings .= " -d " . escapeshellarg($name) . "=" . escapeshellarg($val);
2978+
$deep = false;
2979+
$value = [$value];
2980+
}
2981+
foreach ($value as $val) {
2982+
if (IS_WINDOWS && $deep && strlen($val) >= 2 && str_starts_with($val, '"') && str_ends_with($val, '"')) {
2983+
// hack introduced in cee97080d1f5c7469d4f877698f91ef9f97a3199
2984+
// for unexplained/unknown reasons
2985+
$val = substr($val, strlen('"'), -strlen('"'));
29992986
}
2987+
$settings .= " -d " . escapeshellarg($name) . '=' . escapeshellarg($val);
30002988
}
30012989
}
3002-
30032990
return $settings;
30042991
}
30052992

0 commit comments

Comments
 (0)