Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd6b7fd8

Browse files
[Process] Properly deal with not-found executables on Windows
1 parentf41aa69 commitd6b7fd8

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

‎src/Symfony/Component/Process/ExecutableFinder.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ public function find(string $name, ?string $default = null, array $extraDirs = [
7070
}
7171
}
7272

73-
$command ='\\' === \DIRECTORY_SEPARATOR ?'where' :'command -v --';
74-
if (\function_exists('exec') && ($executablePath =strtok(@exec($command.''.escapeshellarg($name)), \PHP_EOL)) && @is_executable($executablePath)) {
73+
if (!\function_exists('exec') ||\strlen($name) !==strcspn($name,'/'.\DIRECTORY_SEPARATOR)) {
74+
return$default;
75+
}
76+
77+
$command ='\\' === \DIRECTORY_SEPARATOR ?'where %s 2> NUL' :'command -v -- %s';
78+
$execResult =exec(\sprintf($command,escapeshellarg($name)));
79+
80+
if (($executablePath =substr($execResult,0,strpos($execResult, \PHP_EOL) ?:null)) && @is_executable($executablePath)) {
7581
return$executablePath;
7682
}
7783

‎src/Symfony/Component/Process/PhpExecutableFinder.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ public function find(bool $includeArgs = true)
3535
{
3636
if ($php =getenv('PHP_BINARY')) {
3737
if (!is_executable($php)) {
38-
$command ='\\' === \DIRECTORY_SEPARATOR ?'where' :'command -v --';
39-
if (\function_exists('exec') &&$php =strtok(exec($command.''.escapeshellarg($php)), \PHP_EOL)) {
40-
if (!is_executable($php)) {
41-
returnfalse;
42-
}
43-
}else {
38+
if (!\function_exists('exec') ||\strlen($php) !==strcspn($php,'/'.\DIRECTORY_SEPARATOR)) {
39+
returnfalse;
40+
}
41+
42+
$command ='\\' === \DIRECTORY_SEPARATOR ?'where %s 2> NULL' :'command -v -- %s';
43+
$execResult =exec(\sprintf($command,escapeshellarg($php)));
44+
if (!$php =substr($execResult,0,strpos($execResult, \PHP_EOL) ?:null)) {
45+
returnfalse;
46+
}
47+
if (!is_executable($php)) {
4448
returnfalse;
4549
}
4650
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp