From 0f861568aaf186bf395f411ae009bbc3bc3b7436 Mon Sep 17 00:00:00 2001 From: downace Date: Sat, 8 Sep 2018 01:12:13 +0900 Subject: [PATCH] [Console] fixed corrupt error output for unknown multibyte short option --- src/Symfony/Component/Console/Input/ArgvInput.php | 3 ++- src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 741c734c72..2735fce693 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -121,7 +121,8 @@ class ArgvInput extends Input $len = \strlen($name); for ($i = 0; $i < $len; ++$i) { if (!$this->definition->hasShortcut($name[$i])) { - throw new RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); + $encoding = mb_detect_encoding($name, null, true); + throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding))); } $option = $this->definition->getOptionForShortcut($name[$i]); diff --git a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php index 9290d980f6..c81385e3e3 100644 --- a/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php @@ -228,6 +228,11 @@ class ArgvInputTest extends TestCase new InputDefinition(array(new InputArgument('number'))), 'The "-1" option does not exist.', ), + array( + array('cli.php', '-fЩ'), + new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))), + 'The "-Щ" option does not exist.', + ), ); }