bug #28393 [Console] fixed corrupt error output for unknown multibyte short option (downace)
This PR was squashed before being merged into the 2.8 branch (closes #28393).
Discussion
----------
[Console] fixed corrupt error output for unknown multibyte short option
| Q | A
| ------------- | ---
| Branch? | 2.8 <!-- see below -->
| Bug fix? | yes
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | yes <!-- please add some, will be required by reviewers -->
| Fixed tickets | #28320 <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | - <!-- required for new features -->
[Console] Fixed #28320 by using mb_substr instead of index access
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
Commits
-------
0f86156
[Console] fixed corrupt error output for unknown multibyte short option
This commit is contained in:
commit
0417d6caad
@ -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]);
|
||||
|
@ -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.',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user