10000 5.2.6 breaks progress bar when unicode characters are in message · Issue #40633 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

5.2.6 breaks progress bar when unicode characters are in message #40633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
grasmash opened this issue Mar 29, 2021 · 3 comments
Closed

5.2.6 breaks progress bar when unicode characters are in message #40633

grasmash opened this issue Mar 29, 2021 · 3 comments

Comments

@grasmash
Copy link
Contributor
grasmash commented Mar 29, 2021

Symfony version(s) affected: 5.2.6

Description
5.2.6 included these changes to strlenWithoutDecoration() which break the progress bar when a unicode character is used as the progress bar character.

$progress->setProgressCharacter('💧');

How to reproduce
This test case reproduces the issue: https://github.com/acquia/cli/blob/master/tests/phpunit/src/Commands/Pull/PullDatabaseCommandTest.php#L294

The progress bar length is incorrectly calculated and results in an error:

str_repeat(): Second argument has to be greater than or equal to 0
/home/travis/build/acquia/cli/vendor/symfony/console/Helper/ProgressBar.php:517
/home/travis/build/acquia/cli/vendor/symfony/console/Helper/ProgressBar.php:576
/home/travis/build/acquia/cli/vendor/symfony/console/Helper/ProgressBar.php:589
/home/travis/build/acquia/cli/vendor/symfony/console/Helper/ProgressBar.php:414
/home/travis/build/acquia/cli/vendor/symfony/console/Helper/ProgressBar.php:323
/home/travis/build/acquia/cli/src/Output/Spinner/Spinner.php:151
/home/travis/build/acquia/cli/src/Output/Checklist.php:42
/home/travis/build/acquia/cli/tests/phpunit/src/Commands/ChecklistTest.php:28

Possible Solution

Additional context

@grasmash grasmash added the Bug label Mar 29, 2021
@grasmash grasmash changed the title 5.2.6 breaks progress bar in some situations 5.2.6 breaks progress bar when unicode characters are in message Mar 29, 2021
@grasmash
Copy link
Contributor Author

I can confirm that changing $progress->setProgressCharacter('💧'); to $progress->setProgressCharacter('^'); resolves the issue. The scope of the bug impact is known.

@grasmash
Copy link
Contributor Author
grasmash commented Mar 29, 2021

Yeah so this change:
v5.2.5...v5.2.6#diff-c088db8cd42c64b3dd749a6954f5382f124c9e164560f8a789031d36ab48c801R128-R130

        if (preg_match('//u', $string)) {
            return (new UnicodeString($string))->width(true);
        }

Actually causes 💧 to be measured as 2 characters rather than 1, which creates the bug. I believe this is unrelated to #40460 and is related only to this change to strlenWithoutDecoration().

@chalasr
Copy link
Member
chalasr commented Apr 8, 2021

Thank you for the report and the PR. Fixed in #40698

@chalasr chalasr closed this as completed Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0