From 94703ba5765849d171559b8871e6109a317d1da9 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 8 May 2024 17:39:08 +0900 Subject: [PATCH] fix: CLI::prompt() may incorrectly return default value See CLITest::testPromptInputZero(). --- system/CLI/CLI.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 790af4b7a788..7badf1807dcd 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -258,7 +258,8 @@ public static function prompt(string $field, $options = null, $validation = null static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': '); // Read the input from keyboard. - $input = trim(static::$io->input()) ?: (string) $default; + $input = trim(static::$io->input()); + $input = ($input === '') ? (string) $default : $input; if ($validation !== []) { while (! static::validate('"' . trim($field) . '"', $input, $validation)) {