Skip to content

Commit 08ad138

Browse files
committed
Fix inconsistencies in path cleaning
1 parent ef89b11 commit 08ad138

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Tests/CommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,11 @@ public function testCommandString($source, $output, $geometry, $quality, $format
331331
;
332332

333333
$expected = \implode(' ', $command->getExecutable('convert')).
334-
' '.$source.
334+
' \''.$source.'\''.
335335
' -thumbnail "'.$geometry.'"'.
336336
' -quality '.$quality.
337337
' -page "'.$format.'"'.
338-
' '.$output;
338+
' \''.$output.'\'';
339339

340340
$expected = \str_replace('\\', '/', $expected);
341341

src/Command.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function create(?string $magickBinaryPath = null): self
105105
public static function findMagickBinaryPath(?string $magickBinaryPath): string
106106
{
107107
// Delete trimming directory separator
108-
$magickBinaryPath = self::cleanPath((string) $magickBinaryPath, true);
108+
$magickBinaryPath = self::cleanPath((string) $magickBinaryPath, true, false);
109109

110110
if (!$magickBinaryPath) {
111111
$magickBinaryPath = (new ExecutableFinder())->find('magick');
@@ -118,15 +118,17 @@ public static function findMagickBinaryPath(?string $magickBinaryPath): string
118118
return $magickBinaryPath;
119119
}
120120

121-
private static function cleanPath(string $path, bool $rtrim = false): string
121+
private static function cleanPath(string $path, bool $rtrim = false, bool $escape = true): string
122122
{
123123
$path = \str_replace('\\', '/', $path);
124124

125125
if ($rtrim) {
126126
$path = \rtrim($path, '/');
127127
}
128128

129-
$path = \escapeshellarg($path);
129+
if ($escape) {
130+
$path = \escapeshellarg($path);
131+
}
130132

131133
return $path;
132134
}

0 commit comments

Comments
 (0)