10000 bug #28393 [Console] fixed corrupt error output for unknown multibyte… · symfony/symfony@0417d6c · GitHub
[go: up one dir, main page]

Skip to content

Commit 0417d6c

Browse files
author
Robin Chalas
committed
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
2 parents 1c759a1 + 0f86156 commit 0417d6c

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)
0