Skip to content

Commit

Permalink
Improve parameter command quoting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikuolan committed Nov 6, 2024
1 parent 3252326 commit 3268058
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
### v3.4.1

- [2024.11.06]: Added PHP 8.4 to workflows.
- [2024.11.06]: Improved command parameter quoting.
9 changes: 6 additions & 3 deletions src/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* License: GNU/GPLv2
* @see LICENSE.txt
*
* This file: CLI handler (last modified: 2024.10.15).
* This file: CLI handler (last modified: 2024.11.06).
*/

namespace phpMussel\CLI;
Expand Down Expand Up @@ -238,6 +238,9 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
$TargetData = substr($TargetData, 0, -5);
$this->Loader->InstanceCache[$Matches[1]] = true;
}
if (preg_match('~^(["\'])(.+)\1$~', $TargetData, $Matches)) {
$TargetData = $Matches[2];
}
echo "\n" . $this->Scanner->scan($TargetData) . "\n";
if (isset($this->Loader->InstanceCache['Print after CLI scan']) && $this->Loader->InstanceCache['Print after CLI scan'] !== '') {
echo "\n" . $this->Loader->InstanceCache['Print after CLI scan'] . "\n";
Expand Down Expand Up @@ -288,9 +291,9 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
*/
public function recursiveCommand(string $Command, callable $Callable): string
{
if (preg_match('~^([^ "]+) "([^"]+)"$~', $Command, $Matches)) {
if (preg_match('~^([^ "]+) (["\'])(.+)\2$~', $Command, $Matches)) {
$Command = $Matches[1];
$Params = $Matches[2];
$Params = $Matches[3];
} else {
[$Command, $Params] = strpos($Command, ' ') === false ? [$Command, ''] : explode(' ', $Command, 2);
}
Expand Down

0 comments on commit 3268058

Please sign in to comment.