Skip to content

Commit 0f86156

Browse files
downaceRobin Chalas
authored andcommitted
[Console] fixed corrupt error output for unknown multibyte short option
1 parent d32d768 commit 0f86156

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ private function parseShortOptionSet($name)
121121
$len = \strlen($name);
122122
for ($i = 0; $i < $len; ++$i) {
123123
if (!$this->definition->hasShortcut($name[$i])) {
124-
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i]));
124+
$encoding = mb_detect_encoding($name, null, true);
125+
throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
125126
}
126127

127128
$option = $this->definition->getOptionForShortcut($name[$i]);

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ public function provideInvalidInput()
228228
new InputDefinition(array(new InputArgument('number'))),
229229
'The "-1" option does not exist.',
230230
),
231+
array(
232+
array('cli.php', '-fЩ'),
233+
new InputDefinition(array(new InputOption('foo', 'f', InputOption::VALUE_NONE))),
234+
'The "-Щ" option does not exist.',
235+
),
231236
);
232237
}
233238

0 commit comments

Comments
 (0)