password-generator icon indicating copy to clipboard operation
password-generator copied to clipboard

Incompatible with multibyte characters

Open floriankick opened this issue 1 year ago • 4 comments

I tried adding german umlauts (äüö) as valid lower case letters by setting the parameter PARAMETER_LOWER_CASE $passwordGenerator->setParameter(ComputerPasswordGenerator::PARAMETER_LOWER_CASE, 'abcdefghijklmnopqrstuvwxyzöäüß')

Unfortunately this leads to generated passwords containing invalid utf8 characters. I believe the reason is that the library is using the "normal" string functions of PHP.

Is there any plan of upgrading to the multibyte string functions?

floriankick avatar Aug 21 '24 15:08 floriankick

I'm amazed that this issue hasn't been reported before. I'll try and get this sorted in the next 24 hours

hackzilla avatar Aug 22 '24 08:08 hackzilla

@floriankick I've added multibyte support into master. Can you confirm if that works for you?

hackzilla avatar Aug 22 '24 13:08 hackzilla

Thanks for the quick reaction! I tried the current master and generation seems to work fine for me. Only in the validation I found one more spot to correct: $count = strlen(preg_replace('|[^'.preg_quote($this->getParameter($option)).']|', '', $password)); I think mb_strlen and the u-Modifier for the regex pattern should help here.

floriankick avatar Aug 23 '24 08:08 floriankick

@floriankick I've updated those instances, and found a few others as well.

hackzilla avatar Aug 23 '24 17:08 hackzilla

Works like a charm! Thanks again! Would be happy to see those changes being released as a new version on packagist.

floriankick avatar Aug 26 '24 10:08 floriankick

@floriankick I've tagged that as 1.7.0 I would have done it sooner, but I was away on holiday.

hackzilla avatar Sep 01 '24 14:09 hackzilla