-
-
Notifications
You must be signed in to change notification settings - Fork 196
Use ProcessUtils::escapeArgument() instead of escapeshellarg() #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Output\StreamOutput; | ||
use Symfony\Component\Process\PhpExecutableFinder; | ||
use Symfony\Component\Process\ProcessUtils; | ||
|
||
/** | ||
* @author Fabien Potencier <[email protected]> | ||
|
@@ -99,7 +100,7 @@ private function expandSymfonyCmd(string $cmd) | |
return null; | ||
} | ||
|
||
$console = escapeshellarg($this->options->get('bin-dir').'/console'); | ||
$console = ProcessUtils::escapeArgument($this->options->get('bin-dir').'/console'); | ||
if ($this->io->isDecorated()) { | ||
$console .= ' --ansi'; | ||
} | ||
|
@@ -127,8 +128,8 @@ private function expandPhpScript(string $cmd): string | |
$arguments[] = '--php-ini='.$ini; | ||
} | ||
|
||
$phpArgs = implode(' ', array_map('escapeshellarg', $arguments)); | ||
$phpArgs = implode(' ', array_map([ProcessUtils::class, 'escapeArgument'], $arguments)); | ||
|
||
return escapeshellarg($php).($phpArgs ? ' '.$phpArgs : '').' '.$cmd; | ||
return ProcessUtils::escapeArgument($php).($phpArgs ? ' '.$phpArgs : '').' '.$cmd; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be a non-dev requirement ? Otherwise, the method might be undefined at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cannot be a non-dev requirement because that would prevent using flex with symfony >=3 apps.
But flex always runs in a composer context where process 2.8 is always available.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but that would break in case Composer updates that (composer itself is already compatible with different versions of
symfony/process
in case you don't force it to install deps for PHP 5.3)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The composer.json of Composer has config.platform.php set to 5.3.9, so that only process 2.8 is ever installed. Its "require" is misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the composer.lock and the platform config only impact the root project (so the composer phar). I know of other projects bringing in composer as a dependency. And then, newer versions can be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, composer also has its own version of
escapeArgument
precisely because it could not stop using it easily, while they wanted to add support for newer Symfony versionsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that one, fixed in #447