From dcc3255b181330bfce4688e2e042bb8934acc727 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 25 Feb 2023 15:02:06 +0100 Subject: [PATCH] Fix GH-10489: run-tests.php does not escape path when building cmd (#10560) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Multiple tests had to be changed to escape the arguments in shell commands. Some tests are skipped because they behave differently with spaces in the path versus without. One notable example of this is the hashbang test which does not work because spaces in hashbangs paths are not supported in Linux. Co-authored-by: Michael Voříšek --- Zend/tests/bug40236.phpt | 4 +-- Zend/tests/bug60978.phpt | 3 +- ext/com_dotnet/tests/bug77578.phpt | 4 +-- ext/mbstring/tests/gh7902.phpt | 4 ++- ext/simplexml/tests/bug79971_1.phpt | 4 ++- .../tests/directory/bug74589_utf8.phpt | 5 +-- ext/standard/tests/file/bug22414.phpt | 11 +++---- ext/standard/tests/file/bug26615.phpt | 4 +-- ext/standard/tests/file/bug26938.phpt | 2 +- ext/standard/tests/file/bug60120.phpt | 9 ++---- ext/standard/tests/file/mkdir-002.phpt | 3 +- .../tests/file/popen_pclose_basic.phpt | 5 +-- ext/standard/tests/file/proc_open01.phpt | 2 +- .../file/windows_mb_path/bug75063_cp1251.phpt | 2 +- .../file/windows_mb_path/bug75063_utf8.phpt | 2 +- .../tests/general_functions/bug69646.phpt | 2 +- .../tests/general_functions/bug70018.phpt | 3 +- .../general_functions/proc_open-mb0.phpt | 5 +-- .../general_functions/proc_open-mb1.phpt | 5 +-- .../general_functions/proc_open_pipes1.phpt | 4 +-- .../general_functions/proc_open_pipes2.phpt | 4 +-- .../general_functions/proc_open_pipes3.phpt | 11 ++++--- .../tests/ini_info/php_ini_loaded_file.phpt | 4 +-- .../tests/ini_info/php_ini_scanned_files.phpt | 2 +- ext/standard/tests/misc/bug79410.phpt | 2 +- ext/standard/tests/streams/bug46024.phpt | 5 ++- ext/standard/tests/streams/bug70198.phpt | 3 +- ext/standard/tests/streams/bug78883.phpt | 2 +- .../streams/proc_open_bug51800_right.phpt | 4 +-- .../streams/proc_open_bug51800_right2.phpt | 4 +-- .../tests/streams/proc_open_bug60120.phpt | 2 +- .../tests/streams/proc_open_bug64438.phpt | 4 +-- .../tests/streams/proc_open_bug69900.phpt | 2 +- run-tests.php | 31 ++++++++++++++----- sapi/cgi/tests/bug75574_utf8.phpt | 2 +- sapi/cgi/tests/include.inc | 3 +- sapi/cli/tests/001.phpt | 2 +- sapi/cli/tests/002-unix.phpt | 2 +- sapi/cli/tests/002.phpt | 2 +- sapi/cli/tests/003-2.phpt | 6 ++-- sapi/cli/tests/003.phpt | 2 +- sapi/cli/tests/004.phpt | 2 +- sapi/cli/tests/005.phpt | 8 ++--- sapi/cli/tests/006.phpt | 2 +- sapi/cli/tests/007.phpt | 2 +- sapi/cli/tests/008.phpt | 2 +- sapi/cli/tests/009.phpt | 2 +- sapi/cli/tests/010-2.phpt | 5 +-- sapi/cli/tests/010.phpt | 6 ++-- sapi/cli/tests/011.phpt | 9 +++--- sapi/cli/tests/012-2.phpt | 24 +++++++------- sapi/cli/tests/012.phpt | 18 +++++------ sapi/cli/tests/013.phpt | 9 +++--- sapi/cli/tests/014.phpt | 7 +++-- sapi/cli/tests/015.phpt | 10 +++--- sapi/cli/tests/016.phpt | 4 +-- sapi/cli/tests/017.phpt | 2 +- sapi/cli/tests/018.phpt | 4 +-- sapi/cli/tests/019.phpt | 4 +-- sapi/cli/tests/020.phpt | 6 ++-- sapi/cli/tests/021.phpt | 4 +++ sapi/cli/tests/022.phpt | 2 +- sapi/cli/tests/023.phpt | 5 +-- sapi/cli/tests/argv_mb.phpt | 5 +-- sapi/cli/tests/bug61546.phpt | 2 +- sapi/cli/tests/bug62294.phpt | 4 +-- sapi/cli/tests/bug64529.phpt | 2 +- sapi/cli/tests/bug65275.phpt | 4 +-- sapi/cli/tests/bug71624.phpt | 7 +++-- sapi/cli/tests/bug74600.phpt | 5 +-- sapi/cli/tests/bug78323.phpt | 2 +- .../tests/sapi_windows_set_ctrl_handler.phpt | 2 +- sapi/phpdbg/tests/bug73615.phpt | 2 +- tests/basic/bug71273.phpt | 2 +- tests/run-test/extensions-shared.phpt | 2 +- 75 files changed, 198 insertions(+), 160 deletions(-) diff --git a/Zend/tests/bug40236.phpt b/Zend/tests/bug40236.phpt index 35ed84066b8..7ed298c1eed 100644 --- a/Zend/tests/bug40236.phpt +++ b/Zend/tests/bug40236.phpt @@ -6,8 +6,8 @@ if (extension_loaded("readline")) die("skip Test doesn't support readline"); ?> --FILE-- --EXPECT-- diff --git a/Zend/tests/bug60978.phpt b/Zend/tests/bug60978.phpt index 5dc6fe31e71..2d83d2a213e 100644 --- a/Zend/tests/bug60978.phpt +++ b/Zend/tests/bug60978.phpt @@ -2,8 +2,7 @@ Bug #60978 (exit code incorrect) --FILE-- --EXPECT-- diff --git a/ext/com_dotnet/tests/bug77578.phpt b/ext/com_dotnet/tests/bug77578.phpt index 653a1612321..a820935d5d7 100644 --- a/ext/com_dotnet/tests/bug77578.phpt +++ b/ext/com_dotnet/tests/bug77578.phpt @@ -6,8 +6,8 @@ com_dotnet --INI-- sendmail_path={MAIL:{PWD}/gh7902.eml} diff --git a/ext/simplexml/tests/bug79971_1.phpt b/ext/simplexml/tests/bug79971_1.phpt index 1097d74bb29..2ee07c81822 100644 --- a/ext/simplexml/tests/bug79971_1.phpt +++ b/ext/simplexml/tests/bug79971_1.phpt @@ -1,8 +1,10 @@ --TEST-- Bug #79971 (special character is breaking the path in xml function) +--EXTENSIONS-- +simplexml --SKIPIF-- --FILE-- --EXPECTF-- diff --git a/ext/standard/tests/file/bug22414.phpt b/ext/standard/tests/file/bug22414.phpt index 55078568152..49ac237f1ab 100644 --- a/ext/standard/tests/file/bug22414.phpt +++ b/ext/standard/tests/file/bug22414.phpt @@ -6,22 +6,21 @@ output_handler= '.$tmpfile ; + $cmd = $php_escaped . $args . ' -r ' . escapeshellarg('passthru("'.$cmd.'");') . ' > '.escapeshellarg($tmpfile); } else { - $cmd = $php . $args . ' -r \"readfile(@getenv(\\\\\\"TEST_PHP_EXECUTABLE\\\\\\")); \"'; - $cmd = $php . $args . ' -r " passthru(\''.$cmd.'\');" > '.$tmpfile ; + $cmd = $php_escaped . $args . ' -r ' . "\"passthru('".addslashes($cmd)."');\"" . ' > '.escapeshellarg($tmpfile); } exec($cmd); diff --git a/ext/standard/tests/file/bug26615.phpt b/ext/standard/tests/file/bug26615.phpt index 8a5df91ec18..2e652fa3439 100644 --- a/ext/standard/tests/file/bug26615.phpt +++ b/ext/standard/tests/file/bug26615.phpt @@ -7,9 +7,9 @@ variables_order=E $out = array(); $status = -1; if (substr(PHP_OS, 0, 3) != 'WIN') { - exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status); + exec($_ENV['TEST_PHP_EXECUTABLE_ESCAPED'].' -n -r \'for($i=1;$i<=5000;$i++) print "$i\n";\' | tr \'\n\' \' \'', $out, $status); } else { - exec($_ENV['TEST_PHP_EXECUTABLE'].' -n -r "for($i=1;$i<=5000;$i++) echo $i,\' \';"', $out, $status); + exec($_ENV['TEST_PHP_EXECUTABLE_ESCAPED'].' -n -r "for($i=1;$i<=5000;$i++) echo $i,\' \';"', $out, $status); } print_r($out); ?> diff --git a/ext/standard/tests/file/bug26938.phpt b/ext/standard/tests/file/bug26938.phpt index 13732c03f63..eec537d2d97 100644 --- a/ext/standard/tests/file/bug26938.phpt +++ b/ext/standard/tests/file/bug26938.phpt @@ -4,7 +4,7 @@ Bug #26938 (exec does not read consecutive long lines correctly) '); $ds = array( @@ -19,7 +20,7 @@ $ds = array( ); $p = proc_open( - "$php -n $f テストマルチバイト・パス füße карамба", + "$php -n $f_escaped テストマルチバイト・パス füße карамба", $ds, $pipes, NULL, diff --git a/ext/standard/tests/general_functions/proc_open-mb1.phpt b/ext/standard/tests/general_functions/proc_open-mb1.phpt index 8a735cf306e..057979e604c 100644 --- a/ext/standard/tests/general_functions/proc_open-mb1.phpt +++ b/ext/standard/tests/general_functions/proc_open-mb1.phpt @@ -7,9 +7,10 @@ if (!function_exists("proc_open")) echo "skip proc_open() is not available"; --FILE-- '); $ds = array( @@ -19,7 +20,7 @@ $ds = array( ); $p = proc_open( - "$php -n $f テストマルチバイト・パス füße карамба", + "$php -n $f_escaped テストマルチバイト・パス füße карамба", $ds, $pipes ); diff --git a/ext/standard/tests/general_functions/proc_open_pipes1.phpt b/ext/standard/tests/general_functions/proc_open_pipes1.phpt index 076b8c941e2..9822607c6f7 100644 --- a/ext/standard/tests/general_functions/proc_open_pipes1.phpt +++ b/ext/standard/tests/general_functions/proc_open_pipes1.phpt @@ -7,8 +7,8 @@ for ($i = 3; $i<= 30; $i++) { $spec[$i] = array('pipe', 'w'); } -$php = getenv("TEST_PHP_EXECUTABLE"); -$callee = __DIR__ . "/proc_open_pipes_sleep.inc"; +$php = getenv("TEST_PHP_EXECUTABLE_ESCAPED"); +$callee = escapeshellarg(__DIR__ . "/proc_open_pipes_sleep.inc"); proc_open("$php -n $callee", $spec, $pipes); var_dump(count($spec)); diff --git a/ext/standard/tests/general_functions/proc_open_pipes2.phpt b/ext/standard/tests/general_functions/proc_open_pipes2.phpt index 3c1cf969559..c147a2f3764 100644 --- a/ext/standard/tests/general_functions/proc_open_pipes2.phpt +++ b/ext/standard/tests/general_functions/proc_open_pipes2.phpt @@ -5,8 +5,8 @@ proc_open() with no pipes $spec = array(); -$php = getenv("TEST_PHP_EXECUTABLE"); -$callee = __DIR__ . "/proc_open_pipes_sleep.inc"; +$php = getenv("TEST_PHP_EXECUTABLE_ESCAPED"); +$callee = escapeshellarg(__DIR__ . "/proc_open_pipes_sleep.inc"); proc_open("$php -n $callee", $spec, $pipes); var_dump(count($spec)); diff --git a/ext/standard/tests/general_functions/proc_open_pipes3.phpt b/ext/standard/tests/general_functions/proc_open_pipes3.phpt index f5801ad63e4..1ee42904a05 100644 --- a/ext/standard/tests/general_functions/proc_open_pipes3.phpt +++ b/ext/standard/tests/general_functions/proc_open_pipes3.phpt @@ -7,25 +7,26 @@ for ($i = 3; $i<= 5; $i++) { $spec[$i] = array('pipe', 'w'); } -$php = getenv("TEST_PHP_EXECUTABLE"); +$php = getenv("TEST_PHP_EXECUTABLE_ESCAPED"); $callee = __DIR__ . "/proc_open_pipes_sleep.inc"; +$callee_escaped = escapeshellarg($callee); $spec[$i] = array('pi'); -proc_open("$php -n $callee", $spec, $pipes); +proc_open("$php -n $callee_escaped", $spec, $pipes); $spec[$i] = 1; try { - proc_open("$php -n $callee", $spec, $pipes); + proc_open("$php -n $callee_escaped", $spec, $pipes); } catch (ValueError $exception) { echo $exception->getMessage() . "\n"; } $spec[$i] = array('pipe', "test"); -proc_open("$php -n $callee", $spec, $pipes); +proc_open("$php -n $callee_escaped", $spec, $pipes); var_dump($pipes); $spec[$i] = array('file', "test", "z"); -proc_open("$php -n $callee", $spec, $pipes); +proc_open("$php -n $callee_escaped", $spec, $pipes); var_dump($pipes); echo "END\n"; diff --git a/ext/standard/tests/ini_info/php_ini_loaded_file.phpt b/ext/standard/tests/ini_info/php_ini_loaded_file.phpt index b4ad617f9fe..1fce24e67fe 100644 --- a/ext/standard/tests/ini_info/php_ini_loaded_file.phpt +++ b/ext/standard/tests/ini_info/php_ini_loaded_file.phpt @@ -3,14 +3,14 @@ php_ini_loaded_file() function --FILE-- --EXPECTREGEX-- bool\(false\) diff --git a/ext/standard/tests/ini_info/php_ini_scanned_files.phpt b/ext/standard/tests/ini_info/php_ini_scanned_files.phpt index 27d2bebadf1..6f750584fd7 100644 --- a/ext/standard/tests/ini_info/php_ini_scanned_files.phpt +++ b/ext/standard/tests/ini_info/php_ini_scanned_files.phpt @@ -3,7 +3,7 @@ php_ini_scanned_files() function --FILE-- --EXPECT-- diff --git a/ext/standard/tests/streams/bug46024.phpt b/ext/standard/tests/streams/bug46024.phpt index 5a712dcb6b9..79078890ce1 100644 --- a/ext/standard/tests/streams/bug46024.phpt +++ b/ext/standard/tests/streams/bug46024.phpt @@ -2,17 +2,16 @@ Bug #46024 stream_select() doesn't return the correct number --SKIPIF-- --FILE-- array('pipe', 'r'), 1 => array('pipe', 'w')) ,$pipes, __DIR__, array(), array() ); diff --git a/ext/standard/tests/streams/bug70198.phpt b/ext/standard/tests/streams/bug70198.phpt index fc9c30f6fe3..0e122b66e8e 100644 --- a/ext/standard/tests/streams/bug70198.phpt +++ b/ext/standard/tests/streams/bug70198.phpt @@ -17,6 +17,7 @@ server $srv_addr = "tcp://127.0.0.1:8964"; $srv_fl = __DIR__ . "/bug70198_svr_" . md5(uniqid()) . ".php"; +$srv_fl_escaped = escapeshellarg($srv_fl); $srv_fl_cont = << array("file", "stderr.txt", "ab") ); $pipes = []; -$cmd = 'cmd.exe "/c START ^"^" /WAIT ' . PHP_BINARY . ' -r ^"var_dump(fgets(STDIN));"'; +$cmd = 'cmd.exe "/c START ^"^" /WAIT ' . getenv('TEST_PHP_EXECUTABLE_ESCAPED') . ' -r ^"var_dump(fgets(STDIN));"'; $proc = proc_open($cmd, $descriptorspec, $pipes); var_dump(is_resource($proc)); $pid = proc_get_status($proc)['pid']; diff --git a/ext/standard/tests/streams/proc_open_bug51800_right.phpt b/ext/standard/tests/streams/proc_open_bug51800_right.phpt index 1c889f6e987..ba68fa2a208 100644 --- a/ext/standard/tests/streams/proc_open_bug51800_right.phpt +++ b/ext/standard/tests/streams/proc_open_bug51800_right.phpt @@ -9,8 +9,8 @@ if (strpos(PHP_OS, 'FreeBSD') !== false) { --FILE-- array("pipe", "r"),1 => array("pipe", "w")); $pipes = array(); -$process = proc_open(PHP_BINARY.' -n -f ' . $fl, $descriptorspec, $pipes, NULL, NULL, array("blocking_pipes" => true)); +$process = proc_open(getenv('TEST_PHP_EXECUTABLE_ESCAPED').' -n -f ' . escapeshellarg($fl), $descriptorspec, $pipes, NULL, NULL, array("blocking_pipes" => true)); $moreThanLimit = 0; for($i = 0; $i < 10; $i++){ diff --git a/run-tests.php b/run-tests.php index 9b892327c8d..6ff9041a5d0 100755 --- a/run-tests.php +++ b/run-tests.php @@ -678,10 +678,16 @@ function main(): void putenv("TEST_PHP_EXECUTABLE=$php"); $environment['TEST_PHP_EXECUTABLE'] = $php; + putenv("TEST_PHP_EXECUTABLE_ESCAPED=" . escapeshellarg($php)); + $environment['TEST_PHP_EXECUTABLE_ESCAPED'] = escapeshellarg($php); putenv("TEST_PHP_CGI_EXECUTABLE=$php_cgi"); $environment['TEST_PHP_CGI_EXECUTABLE'] = $php_cgi; + putenv("TEST_PHP_CGI_EXECUTABLE_ESCAPED=" . escapeshellarg($php_cgi)); + $environment['TEST_PHP_CGI_EXECUTABLE_ESCAPED'] = escapeshellarg($php_cgi); putenv("TEST_PHPDBG_EXECUTABLE=$phpdbg"); $environment['TEST_PHPDBG_EXECUTABLE'] = $phpdbg; + putenv("TEST_PHPDBG_EXECUTABLE_ESCAPED=" . escapeshellarg($phpdbg)); + $environment['TEST_PHPDBG_EXECUTABLE_ESCAPED'] = escapeshellarg($phpdbg); if ($conf_passed !== null) { if (IS_WINDOWS) { @@ -831,6 +837,7 @@ function verify_config(): void function write_information(): void { global $php, $php_cgi, $phpdbg, $php_info, $user_tests, $ini_overwrites, $pass_options, $exts_to_test, $valgrind, $no_file_cache; + $php_escaped = escapeshellarg($php); // Get info from php $info_file = __DIR__ . '/run-test-info.php'; @@ -846,11 +853,12 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n" $info_params = []; settings2array($ini_overwrites, $info_params); $info_params = settings2params($info_params); - $php_info = shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\""); - define('TESTED_PHP_VERSION', shell_exec("$php -n -r \"echo PHP_VERSION;\"")); + $php_info = shell_exec("$php_escaped $pass_options $info_params $no_file_cache \"$info_file\""); + define('TESTED_PHP_VERSION', shell_exec("$php_escaped -n -r \"echo PHP_VERSION;\"")); if ($php_cgi && $php != $php_cgi) { - $php_info_cgi = shell_exec("$php_cgi $pass_options $info_params $no_file_cache -q \"$info_file\""); + $php_cgi_escaped = escapeshellarg($php_cgi); + $php_info_cgi = shell_exec("$php_cgi_escaped $pass_options $info_params $no_file_cache -q \"$info_file\""); $php_info_sep = "\n---------------------------------------------------------------------"; $php_cgi_info = "$php_info_sep\nPHP : $php_cgi $php_info_cgi$php_info_sep"; } else { @@ -858,7 +866,8 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n" } if ($phpdbg) { - $phpdbg_info = shell_exec("$phpdbg $pass_options $info_params $no_file_cache -qrr \"$info_file\""); + $phpdbg_escaped = escapeshellarg($phpdbg); + $phpdbg_info = shell_exec("$phpdbg_escaped $pass_options $info_params $no_file_cache -qrr \"$info_file\""); $php_info_sep = "\n---------------------------------------------------------------------"; $phpdbg_info = "$php_info_sep\nPHP : $phpdbg $phpdbg_info$php_info_sep"; } else { @@ -884,7 +893,7 @@ More .INIs : " , (function_exists(\'php_ini_scanned_files\') ? str_replace("\n" } echo implode(',', $exts); PHP); - $extensionsNames = explode(',', shell_exec("$php $pass_options $info_params $no_file_cache \"$info_file\"")); + $extensionsNames = explode(',', shell_exec("$php_escaped $pass_options $info_params $no_file_cache \"$info_file\"")); $exts_to_test = array_unique(remap_loaded_extensions_names($extensionsNames)); // check for extensions that need special handling and regenerate $info_params_ex = [ @@ -1163,6 +1172,13 @@ function system_with_timeout( ) { global $valgrind; + // when proc_open cmd is passed as a string (without bypass_shell=true option) the cmd goes thru shell + // and on Windows quotes are discarded, this is a fix to honor the quotes and allow values containing + // spaces like '"C:\Program Files\PHP\php.exe"' to be passed as 1 argument correctly + if (IS_WINDOWS) { + $commandline = 'start "" /b /wait ' . $commandline; + } + $data = ''; $bin_env = []; @@ -1838,6 +1854,7 @@ function run_test(string $php, $file, array $env): string $org_file = $file; $orig_php = $php; + $php = escapeshellarg($php); $php_cgi = $env['TEST_PHP_CGI_EXECUTABLE'] ?? null; $phpdbg = $env['TEST_PHPDBG_EXECUTABLE'] ?? null; @@ -1898,7 +1915,7 @@ TEST $file if (!$php_cgi) { return skip_test($tested, $tested_file, $shortname, 'CGI not available'); } - $php = $php_cgi . ' -C '; + $php = escapeshellarg($php_cgi) . ' -C '; $uses_cgi = true; if ($num_repeats > 1) { return skip_test($tested, $tested_file, $shortname, 'CGI does not support --repeat'); @@ -1909,7 +1926,7 @@ TEST $file $extra_options = ''; if ($test->hasSection('PHPDBG')) { if (isset($phpdbg)) { - $php = $phpdbg . ' -qIb'; + $php = escapeshellarg($phpdbg) . ' -qIb'; // Additional phpdbg command line options for sections that need to // be run straight away. For example, EXTENSIONS, SKIPIF, CLEAN. diff --git a/sapi/cgi/tests/bug75574_utf8.phpt b/sapi/cgi/tests/bug75574_utf8.phpt index 9cbd51abfbd..76d2d8c1f4c 100644 --- a/sapi/cgi/tests/bug75574_utf8.phpt +++ b/sapi/cgi/tests/bug75574_utf8.phpt @@ -13,7 +13,7 @@ include "skipif.inc"; include "include.inc"; -$php = get_cgi_path(); +$php = escapeshellarg(get_cgi_path()); reset_env_vars(); $fn = __DIR__ . DIRECTORY_SEPARATOR . md5(uniqid()); diff --git a/sapi/cgi/tests/include.inc b/sapi/cgi/tests/include.inc index de526723df0..d155edf4ba2 100644 --- a/sapi/cgi/tests/include.inc +++ b/sapi/cgi/tests/include.inc @@ -3,12 +3,13 @@ function get_cgi_path() /* {{{ */ { $php = getenv("TEST_PHP_EXECUTABLE"); + $php_escaped = getenv("TEST_PHP_EXECUTABLE_ESCAPED"); $cli = false; $cgi = false; if (file_exists($php) && is_executable($php)) { - $version = `$php -n -v`; + $version = `$php_escaped -n -v`; if (strstr($version, "(cli)")) { /* that's cli */ $cli = true; diff --git a/sapi/cli/tests/001.phpt b/sapi/cli/tests/001.phpt index ede63ffb033..aced33623ef 100644 --- a/sapi/cli/tests/001.phpt +++ b/sapi/cli/tests/001.phpt @@ -5,7 +5,7 @@ version string --FILE-- --EXPECT-- diff --git a/sapi/cli/tests/003.phpt b/sapi/cli/tests/003.phpt index 63e812d4a7c..20bf61a247b 100644 --- a/sapi/cli/tests/003.phpt +++ b/sapi/cli/tests/003.phpt @@ -10,7 +10,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { --FILE-- diff --git a/sapi/cli/tests/006.phpt b/sapi/cli/tests/006.phpt index 1f2af9c6b63..9d693f65969 100644 --- a/sapi/cli/tests/006.phpt +++ b/sapi/cli/tests/006.phpt @@ -15,7 +15,7 @@ date.timezone=UTC --FILE-- --CLEAN-- diff --git a/sapi/cli/tests/011.phpt b/sapi/cli/tests/011.phpt index 24eb9fc2dff..bd61b260f5a 100644 --- a/sapi/cli/tests/011.phpt +++ b/sapi/cli/tests/011.phpt @@ -5,9 +5,10 @@ syntax check --FILE-- diff --git a/sapi/cli/tests/012.phpt b/sapi/cli/tests/012.phpt index 08ec4ecb1c7..be21b3d99e8 100644 --- a/sapi/cli/tests/012.phpt +++ b/sapi/cli/tests/012.phpt @@ -5,16 +5,16 @@ invalid arguments and error messages --FILE-- diff --git a/sapi/cli/tests/013.phpt b/sapi/cli/tests/013.phpt index 0684b8d0573..345a489403a 100644 --- a/sapi/cli/tests/013.phpt +++ b/sapi/cli/tests/013.phpt @@ -10,14 +10,15 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { --FILE-- &1 | grep Usage:`; +echo `$php -n --version | grep built:`; +echo `echo "&1 | grep Usage:`; echo "Done\n"; ?> diff --git a/sapi/cli/tests/016.phpt b/sapi/cli/tests/016.phpt index c7ce07913f1..544633f592f 100644 --- a/sapi/cli/tests/016.phpt +++ b/sapi/cli/tests/016.phpt @@ -11,7 +11,7 @@ if (readline_info('done') === NULL) { ?> --FILE-- $code) { echo "\n--------------\nSnippet no. $key:\n--------------\n"; $code = escapeshellarg($code); - echo `echo $code | "$php" -a`, "\n"; + echo `echo $code | $php -a`, "\n"; } echo "\nDone\n"; diff --git a/sapi/cli/tests/017.phpt b/sapi/cli/tests/017.phpt index d2d37b18589..6adbf195e2e 100644 --- a/sapi/cli/tests/017.phpt +++ b/sapi/cli/tests/017.phpt @@ -11,7 +11,7 @@ if (readline_info('done') !== NULL) { ?> --FILE-- diff --git a/sapi/cli/tests/019.phpt b/sapi/cli/tests/019.phpt index e8404d835e5..0f5a66c871e 100644 --- a/sapi/cli/tests/019.phpt +++ b/sapi/cli/tests/019.phpt @@ -10,10 +10,10 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { --FILE-- diff --git a/sapi/cli/tests/020.phpt b/sapi/cli/tests/020.phpt index fb7bcb4e7b5..3ccd6a83d3b 100644 --- a/sapi/cli/tests/020.phpt +++ b/sapi/cli/tests/020.phpt @@ -10,11 +10,11 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { --FILE-- diff --git a/sapi/cli/tests/021.phpt b/sapi/cli/tests/021.phpt index 837f64109d0..9a24ec454a9 100644 --- a/sapi/cli/tests/021.phpt +++ b/sapi/cli/tests/021.phpt @@ -7,6 +7,10 @@ if (substr(PHP_OS, 0, 3) == 'WIN') { die ("skip not for Windows"); } +if (str_contains(getenv('TEST_PHP_EXECUTABLE'), " ")) { + die("skip shebang cannot have spaces in its path"); +} + if (strlen("#!".getenv('TEST_PHP_EXECUTABLE')) > 127) { die ("skip shebang is too long, see http://www.in-ulm.de/~mascheck/various/shebang/#results"); } diff --git a/sapi/cli/tests/022.phpt b/sapi/cli/tests/022.phpt index 40c22653518..1afb5fc371a 100644 --- a/sapi/cli/tests/022.phpt +++ b/sapi/cli/tests/022.phpt @@ -7,7 +7,7 @@ if (substr(PHP_OS, 0, 3) == "WIN") die("skip non windows test"); ?> --FILE-- --FILE-- array("pipe", "w"), ); $pipes = array(); -$proc = proc_open("$php -c $ini_file -r 'echo ini_get(\"memory_limit\");'", $desc, $pipes); +$proc = proc_open("$php -c $ini_file_escaped -r 'echo ini_get(\"memory_limit\");'", $desc, $pipes); if (!$proc) { exit(1); } diff --git a/sapi/cli/tests/argv_mb.phpt b/sapi/cli/tests/argv_mb.phpt index 5ed5cef3437..f7f6dd49081 100644 --- a/sapi/cli/tests/argv_mb.phpt +++ b/sapi/cli/tests/argv_mb.phpt @@ -7,12 +7,13 @@ include "skipif.inc"; --FILE-- "); -var_dump(`$php -n $argv_fl 多字节字符串 マルチバイト文字列 многобайтоваястрока flerbytesträng`); +var_dump(`$php -n $argv_fl_escaped 多字节字符串 マルチバイト文字列 многобайтоваястрока flerbytesträng`); @unlink($argv_fl); diff --git a/sapi/cli/tests/bug61546.phpt b/sapi/cli/tests/bug61546.phpt index 071edb72244..67b53147217 100644 --- a/sapi/cli/tests/bug61546.phpt +++ b/sapi/cli/tests/bug61546.phpt @@ -11,7 +11,7 @@ Bug #61546 (functions related to current script failed when chdir() in cli sapi) // the ext/standard/tests/file/statpage.phpt test also tests getmyinode() returns an integer and will // pass even if that integer is 0. on Windows, the getmyinode() call in statpage.phpt returns 0 and // passes on Windows. -$php = getenv("TEST_PHP_EXECUTABLE"); +$php = getenv("TEST_PHP_EXECUTABLE_ESCAPED"); $test_code = << diff --git a/sapi/cli/tests/bug64529.phpt b/sapi/cli/tests/bug64529.phpt index dd7b809cfbc..44df61020e4 100644 --- a/sapi/cli/tests/bug64529.phpt +++ b/sapi/cli/tests/bug64529.phpt @@ -18,7 +18,7 @@ if ($ret) { --FILE-- diff --git a/sapi/cli/tests/bug71624.phpt b/sapi/cli/tests/bug71624.phpt index 8b82ebab58c..83f48cf921c 100644 --- a/sapi/cli/tests/bug71624.phpt +++ b/sapi/cli/tests/bug71624.phpt @@ -7,9 +7,10 @@ include "skipif.inc"; --FILE-- --FILE-- array("pipe", "w"), ); $pipes = array(); -$proc = proc_open("$php -c $ini_file -r 'echo \"okey\";'", $desc, $pipes); +$proc = proc_open("$php -c $ini_file_escaped -r 'echo \"okey\";'", $desc, $pipes); if (!$proc) { exit(1); } diff --git a/sapi/cli/tests/bug78323.phpt b/sapi/cli/tests/bug78323.phpt index 02b18e02a21..d353281a0e8 100644 --- a/sapi/cli/tests/bug78323.phpt +++ b/sapi/cli/tests/bug78323.phpt @@ -6,7 +6,7 @@ include "skipif.inc"; ?> --FILE-- ["pipe", "r"], 1 => ["pipe", "w"]]; $proc = proc_open($cmd, $spec, $pipes, NULL, NULL, ["bypass_shell" => true, "create_process_group" => true]); diff --git a/sapi/phpdbg/tests/bug73615.phpt b/sapi/phpdbg/tests/bug73615.phpt index e5fccef0a85..2208cdebf70 100644 --- a/sapi/phpdbg/tests/bug73615.phpt +++ b/sapi/phpdbg/tests/bug73615.phpt @@ -7,7 +7,7 @@ if (!getenv('TEST_PHPDBG_EXECUTABLE')) die("SKIP: No TEST_PHPDBG_EXECUTABLE spec --FILE-- &1"; + $cmd = getenv('TEST_PHP_EXECUTABLE_ESCAPED') . " -n -d html_errors=on -d extension_dir=a//w -d extension=php_kartoffelbrei.dll -v 2>&1"; $out = shell_exec($cmd); var_dump(preg_match(",.+a[\\/].+[\\/]w.php_kartoffelbrei.dll.+,s", $out)); diff --git a/tests/run-test/extensions-shared.phpt b/tests/run-test/extensions-shared.phpt index e8d9b52aa98..2bbe8b76765 100644 --- a/tests/run-test/extensions-shared.phpt +++ b/tests/run-test/extensions-shared.phpt @@ -4,7 +4,7 @@ phpt EXTENSIONS directive - shared module openssl --SKIPIF--