From 9e2d4a7f348979367be5ddad388516bb8f8a8c51 Mon Sep 17 00:00:00 2001 From: Nathaniel Rogers Date: Wed, 24 Jan 2018 13:17:57 +1000 Subject: [PATCH 1/4] Added support for PHP paths with spaces in Magento CLI --- app/code/Magento/Deploy/Model/Filesystem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index 0557914f48d24..ea01d6db06e52 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -115,7 +115,7 @@ public function __construct( $this->userCollection = $userCollection; $this->locale = $locale; $this->functionCallPath = - PHP_BINARY . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; + '"' . PHP_BINARY . '"' . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; } /** From 1e7bc4c1c6df31fc2c7cbbab4ef6d94bd8b58d36 Mon Sep 17 00:00:00 2001 From: Nathaniel Rogers Date: Thu, 25 Jan 2018 11:17:24 +1000 Subject: [PATCH 2/4] Added fix to expected FilesystemTest to go along with the quoted binary change --- app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php index d14c86c4a3264..d5ec823428550 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php @@ -107,7 +107,7 @@ protected function setUp() ] ); - $this->cmdPrefix = PHP_BINARY . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; + $this->cmdPrefix = '"' . PHP_BINARY . "'" . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; } public function testRegenerateStatic() From 063e7246e032d9e6dfc2e21cc0582def55bec716 Mon Sep 17 00:00:00 2001 From: Nathaniel Rogers Date: Thu, 25 Jan 2018 11:19:11 +1000 Subject: [PATCH 3/4] Refactored to use the escapeshellcmd command for sanitizing the PHP library path --- app/code/Magento/Deploy/Model/Filesystem.php | 2 +- app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index ea01d6db06e52..a67bb045971be 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -115,7 +115,7 @@ public function __construct( $this->userCollection = $userCollection; $this->locale = $locale; $this->functionCallPath = - '"' . PHP_BINARY . '"' . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; + escapeshellcmd(PHP_BINARY) . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; } /** diff --git a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php index d5ec823428550..a89416db3c9b4 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php @@ -107,7 +107,7 @@ protected function setUp() ] ); - $this->cmdPrefix = '"' . PHP_BINARY . "'" . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; + $this->cmdPrefix = escapeshellcmd(PHP_BINARY) . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; } public function testRegenerateStatic() From a5027aac981cd74e77b26f96dbf2cbf0c3972aa5 Mon Sep 17 00:00:00 2001 From: Nathaniel Rogers Date: Thu, 25 Jan 2018 11:28:28 +1000 Subject: [PATCH 4/4] The escapeshellcmd did not escape the binary path in a useable way, reverted to wrapping it in double quotes --- app/code/Magento/Deploy/Model/Filesystem.php | 2 +- app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Deploy/Model/Filesystem.php b/app/code/Magento/Deploy/Model/Filesystem.php index a67bb045971be..ea01d6db06e52 100644 --- a/app/code/Magento/Deploy/Model/Filesystem.php +++ b/app/code/Magento/Deploy/Model/Filesystem.php @@ -115,7 +115,7 @@ public function __construct( $this->userCollection = $userCollection; $this->locale = $locale; $this->functionCallPath = - escapeshellcmd(PHP_BINARY) . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; + '"' . PHP_BINARY . '"' . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; } /** diff --git a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php index a89416db3c9b4..d5ec823428550 100644 --- a/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php +++ b/app/code/Magento/Deploy/Test/Unit/Model/FilesystemTest.php @@ -107,7 +107,7 @@ protected function setUp() ] ); - $this->cmdPrefix = escapeshellcmd(PHP_BINARY) . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; + $this->cmdPrefix = '"' . PHP_BINARY . "'" . ' -f ' . BP . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'magento '; } public function testRegenerateStatic()