Bug #72547 [Com]: \p{Ll} fails to match accented lowercase characters.

From: Date: Tue, 05 Jul 2016 13:16:23 +0000
Subject: Bug #72547 [Com]: \p{Ll} fails to match accented lowercase characters.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202068@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72547&edit=1 ID: 72547 Comment by: sprunka at gmail dot com Reported by: sprunka at gmail dot com Summary: \p{Ll} fails to match accented lowercase characters. Status: Open Type: Bug Package: PCRE related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Here is the example code running in 3v4l.org: https://3v4l.org/hCcqj Previous Comments: ------------------------------------------------------------------------ [2016-07-05 13:14:18] sprunka at gmail dot com Description: ------------ While testing code for matching password complexity, I noticed the \p{Lu} matches all uppercase characters correctly, but \p{Ll} fails to match accented characters. The German "double s" character is debatable whether it should pass or fail. It is definitively a lowercase character, but it has no uppercase variant. Therefore, by definition or \p{Ll} it should not match, but all other cases I can find for it in PCRE examples do have it match \p{Ll}. I have included it as passing as a lower case in the "expected" results below. Test script: --------------- <?php // SHOULD PASS. Passes all 5.0.5 and thereafter. $passwordTestArray[] = 'Aa'; // SHOULD PASS. Passes all 5.0.5 and thereafter. $passwordTestArray[] = 'Æa'; // SHOULD PASS. Fails after 5.2.10. Passes 5.0.5 - 5.2.9 $passwordTestArray[] = 'Aæ'; // SHOULD PASS. Fails after 5.2.10. Passes 5.0.5 - 5.2.9 $passwordTestArray[] = 'Ææ'; // SHOULD FAIL because ß does not have an uppercase equiv. But it passses anyway in 5.0.5 - 5.2.9 $passwordTestArray[] = 'Aß'; // SHOULD FAIL because there is no uppercase ß. // It fails for the wrong reasons in 5.0.5 - 5.2.9 // It passes in 5.2.10 and beyond. $passwordTestArray[] = 'aß'; class PCREFail { static public function verifyComplexity($plainTextPassword) { $re = "/(?=.*[\\p{Ll}])(?=.*[\\p{Lu}]).{2,}/"; $found = preg_match_all($re, $plainTextPassword, $matches); if ($found) { return $matches; } return $found; } } foreach ($passwordTestArray as $passwordToTest) { var_dump(PCREFail::verifyComplexity($passwordToTest)); } Expected result: ---------------- array(1) { [0]=> array(1) { [0]=> string(2) "Aa" } } array(1) { [0]=> array(1) { [0]=> string(3) "Æa" } } array(1) { [0]=> array(1) { [0]=> string(3) "Aæ" } } array(1) { [0]=> array(1) { [0]=> string(4) "Ææ" } } array(1) { [0]=> array(1) { [0]=> string(3) "Aß" } } int(0) Actual result: -------------- array(1) { [0]=> array(1) { [0]=> string(2) "Aa" } } array(1) { [0]=> array(1) { [0]=> string(3) "Æa" } } int(0) int(0) int(0) array(1) { [0]=> array(1) { [0]=> string(3) "aß" } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72547&edit=1

« previous php.bugs (#202068) next »