Thanks to visit codestin.com
Credit goes to github.com

Skip to content

QuestionHelper input truncated at 4095 byte #47586

Closed
@pbek

Description

@pbek

Symfony version(s) affected

6.2

Description

When you ask for input with QuestionHelper the input is truncated at 4096 byte.
The maximum line length in unix terminals is 4096. QuestionHelper additionally only reads the first 4096 byte of the input in:

$value = fgets($inputStream, 4096);

How to reproduce

# Enter a very long string here
php bin/console secrets:set CERT_P12
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $io = new SymfonyStyle($input, $errOutput);

        $value = $io->askHidden('Please type the secret value');
    }

See:

$value = $io->askHidden('Please type the secret value');

The content of $value is truncated to 4095 byte when you enter a text longer than that.

Possible Solution

Maybe a warning should be printed when an input has exactly 4095 characters to alert the user that there is the possibility that something was truncated.

Additional Context

Use case:
We use the Symfony CLI to set secrets (SecretsSetCommand, secret:set). We have very long strings, like base64 encoded certificates in our secrets.

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