Skip to content

[Console] Corrupt error output for unknown multibyte short option #28320

@downace

Description

@downace

Symfony version(s) affected: 4.1.4

Description

Error contains only first byte of multibyte short option

How to reproduce

  1. composer require symfony/console:4.1.4
  2. Create application.php with simple command. Example:
#!/usr/bin/env php
<?php

require __DIR__.'/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

$application = new Application();

$application->add(new class extends Command {
    public function getName() {
        return 'do';
    }

    public function execute(InputInterface $input, OutputInterface $output) {
    }
});

$application->run();
  1. ./application.php do -С 10 (where С is Cyrillic; you can use another letter, e.g. Щ)

Possible Solution

Use mb_substr instead of index access in \Symfony\Component\Console\Input\ArgvInput::parseShortOptionSet

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions