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

Appearance settings

Commit 44ce9fa

Browse filesBrowse files
bug #58711 [Process] Fix handling empty path found in the PATH env var with ExecutableFinder (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [Process] Fix handling empty path found in the PATH env var with ExecutableFinder | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Commits ------- c40ec9c [Process] Fix handling empty path found in the PATH env var with ExecutableFinder
2 parents f41aa69 + c40ec9c commit 44ce9fa
Copy full SHA for 44ce9fa

File tree

2 files changed

+24
-0
lines changed
Filter options

2 files changed

+24
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/ExecutableFinder.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public function find(string $name, ?string $default = null, array $extraDirs = [
6060
}
6161
foreach ($suffixes as $suffix) {
6262
foreach ($dirs as $dir) {
63+
if ('' === $dir) {
64+
$dir = '.';
65+
}
6366
if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
6467
return $file;
6568
}

‎src/Symfony/Component/Process/Tests/ExecutableFinderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Tests/ExecutableFinderTest.php
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ public function testFindWithOpenBaseDir()
111111
}
112112
}
113113

114+
/**
115+
* @runInSeparateProcess
116+
*/
114117
public function testFindBatchExecutableOnWindows()
115118
{
116119
if (\ini_get('open_basedir')) {
@@ -138,6 +141,24 @@ public function testFindBatchExecutableOnWindows()
138141
$this->assertSamePath($target.'.BAT', $result);
139142
}
140143

144+
/**
145+
* @runInSeparateProcess
146+
*/
147+
public function testEmptyDirInPath()
148+
{
149+
putenv(sprintf('PATH=%s:', \dirname(\PHP_BINARY)));
150+
151+
touch('executable');
152+
chmod('executable', 0700);
153+
154+
$finder = new ExecutableFinder();
155+
$result = $finder->find('executable');
156+
157+
$this->assertSame('./executable', $result);
158+
159+
unlink('executable');
160+
}
161+
141162
private function assertSamePath($expected, $tested)
142163
{
143164
if ('\\' === \DIRECTORY_SEPARATOR) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.