From 0ff8b37e187ab97438328d2e499b1d28bd7051ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 4 Oct 2024 13:10:18 +0000 Subject: [PATCH] Apply fix for equals in values --- src/CLI/CLI.php | 2 +- tests/CLI/CLITest.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/CLI/CLI.php b/src/CLI/CLI.php index 0f437e8..a1a2b14 100644 --- a/src/CLI/CLI.php +++ b/src/CLI/CLI.php @@ -244,7 +244,7 @@ public function parse(array $args): array unset($arg); foreach ($args as $arg) { - $pair = explode('=', $arg); + $pair = explode('=', $arg, 2); $key = $pair[0]; $value = $pair[1]; $output[$key][] = $value; diff --git a/tests/CLI/CLITest.php b/tests/CLI/CLITest.php index 26d61ab..a465956 100755 --- a/tests/CLI/CLITest.php +++ b/tests/CLI/CLITest.php @@ -247,4 +247,26 @@ public function testMatch() $this->assertEquals(null, $cli->match()); } + + public function testEscaping() + { + ob_start(); + + $database = 'appwrite://database_db_fra1_self_hosted_0_0?database=appwrite&namespace=_1'; + + $cli = new CLI(new Generic(), ['test.php', 'connect', '--database='.$database]); + + $cli + ->task('connect') + ->param('database', null, new Text(2048), 'Database DSN') + ->action(function ($database) { + echo $database; + }); + + $cli->run(); + + $result = ob_get_clean(); + + $this->assertEquals($database, $result); + } }