Skip to content

Commit

Permalink
The options need to be escaped separately
Browse files Browse the repository at this point in the history
  • Loading branch information
grappler committed May 10, 2022
1 parent 55c4289 commit d1a08bd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Plugin/Patches.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ protected function getAndApplyPatch(RemoteFilesystem $downloader, $install_path,
// differences between how patch works on windows and unix.
$patch_options = '--no-backup-if-mismatch';
if (PHP_OS_FAMILY == 'BSD') {
$patch_options = '--posix --batch';
$patch_options = ['--posix', '--batch'];
}
foreach ($patch_levels as $patch_level) {
if ($patched = $this->executeCommand(
Expand Down Expand Up @@ -502,7 +502,15 @@ protected function executeCommand($cmd)
// Shell-escape all arguments except the command.
$args = func_get_args();
foreach ($args as $index => $arg) {
if ($index !== 0) {
if ($index === 0) {
continue;
}
if (is_array($arg)) {
$args[$index] = '';
foreach ($arg as $option) {
$args[$index] .= ' ' . escapeshellarg($option);
}
} else {
$args[$index] = escapeshellarg($arg);
}
}
Expand Down

0 comments on commit d1a08bd

Please sign in to comment.