Bug #72547 [Com]: \p{Ll} fails to match accented lowercase characters.
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: Not a bug
Type: Bug
Package: PCRE related
Operating System: All
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
That is fantastic. Thank you. However, if it's not a bug, why does \p{Lu} seem to work without
the u modifier, but \p{Ll} does not? Surely one or the other must be a bug, given the inconsistency.
Previous Comments:
------------------------------------------------------------------------
[2016-07-05 15:10:21] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
When working with UTF-8, you should use the u modifier, see
<https://3v4l.org/iOJl3>.
------------------------------------------------------------------------
[2016-07-05 13:16:22] sprunka at gmail dot com
Here is the example code running in 3v4l.org:
https://3v4l.org/hCcqj
------------------------------------------------------------------------
[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
Thread (5 messages)