From 654af640a41838950a6d05e36ff362e06f833763 Mon Sep 17 00:00:00 2001 From: Jonas Schmidt Date: Sat, 7 Dec 2024 11:47:25 +0100 Subject: [PATCH 1/2] Wrap file path in quotes to allow files with spaces --- .gitignore | 2 ++ src/Command.php | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index ec2749f..76fe1bd 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ phpunit.xml ImageMagick*.tar.gz /ImageMagick-*/ + +.idea \ No newline at end of file diff --git a/src/Command.php b/src/Command.php index 1f707bd..686c78f 100644 --- a/src/Command.php +++ b/src/Command.php @@ -126,6 +126,9 @@ private static function cleanPath(string $path, bool $rtrim = false): string $path = \rtrim($path, '/'); } + $path = \trim($path, '"'); + $path = '"' . $path . '"'; + return $path; } From 88bdcc1c1443a85dac2b3c35eddc0aca4774b095 Mon Sep 17 00:00:00 2001 From: Jonas Schmidt Date: Sun, 8 Dec 2024 12:23:56 +0100 Subject: [PATCH 2/2] Use PHP build-in function escapeshellarg for filepath --- .gitignore | 4 +--- src/Command.php | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 76fe1bd..837729d 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,4 @@ phpunit.xml .phpunit.cache ImageMagick*.tar.gz -/ImageMagick-*/ - -.idea \ No newline at end of file +/ImageMagick-*/ \ No newline at end of file diff --git a/src/Command.php b/src/Command.php index 686c78f..9fb66f7 100644 --- a/src/Command.php +++ b/src/Command.php @@ -126,8 +126,7 @@ private static function cleanPath(string $path, bool $rtrim = false): string $path = \rtrim($path, '/'); } - $path = \trim($path, '"'); - $path = '"' . $path . '"'; + $path = \escapeshellarg($path); return $path; }