From 0d6e4c6b4b20bbc3de9519e5eb719712916101cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Fri, 4 Oct 2024 13:07:19 +0000 Subject: [PATCH] Equals symbol test & fix --- 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 c76a852..e8d5e25 100644 --- a/src/CLI/CLI.php +++ b/src/CLI/CLI.php @@ -245,7 +245,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 134bdb4..dd19071 100755 --- a/tests/CLI/CLITest.php +++ b/tests/CLI/CLITest.php @@ -258,4 +258,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); + } }