Skip to content

Commit 3268058

Browse files
committed
Improve parameter command quoting.
1 parent 3252326 commit 3268058

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
5959
### v3.4.1
6060

6161
- [2024.11.06]: Added PHP 8.4 to workflows.
62+
- [2024.11.06]: Improved command parameter quoting.

src/CLI.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: CLI handler (last modified: 2024.10.15).
11+
* This file: CLI handler (last modified: 2024.11.06).
1212
*/
1313

1414
namespace phpMussel\CLI;
@@ -238,6 +238,9 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
238238
$TargetData = substr($TargetData, 0, -5);
239239
$this->Loader->InstanceCache[$Matches[1]] = true;
240240
}
241+
if (preg_match('~^(["\'])(.+)\1$~', $TargetData, $Matches)) {
242+
$TargetData = $Matches[2];
243+
}
241244
echo "\n" . $this->Scanner->scan($TargetData) . "\n";
242245
if (isset($this->Loader->InstanceCache['Print after CLI scan']) && $this->Loader->InstanceCache['Print after CLI scan'] !== '') {
243246
echo "\n" . $this->Loader->InstanceCache['Print after CLI scan'] . "\n";
@@ -288,9 +291,9 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
288291
*/
289292
public function recursiveCommand(string $Command, callable $Callable): string
290293
{
291-
if (preg_match('~^([^ "]+) "([^"]+)"$~', $Command, $Matches)) {
294+
if (preg_match('~^([^ "]+) (["\'])(.+)\2$~', $Command, $Matches)) {
292295
$Command = $Matches[1];
293-
$Params = $Matches[2];
296+
$Params = $Matches[3];
294297
} else {
295298
[$Command, $Params] = strpos($Command, ' ') === false ? [$Command, ''] : explode(' ', $Command, 2);
296299
}

0 commit comments

Comments
 (0)