mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
allow password complexity to work using mbstring if PCRE does not support unicode properties
git-svn-id: file:///svn/phpbb/trunk@7249 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
21ff4e4190
commit
c6b0b62165
1 changed files with 29 additions and 3 deletions
|
@ -1254,6 +1254,8 @@ function validate_password($password)
|
|||
return false;
|
||||
}
|
||||
|
||||
$pcre = $mbstring = false;
|
||||
|
||||
// generic UTF-8 character types supported?
|
||||
if (version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>=')))
|
||||
{
|
||||
|
@ -1261,6 +1263,16 @@ function validate_password($password)
|
|||
$low = '\p{Ll}';
|
||||
$num = '\p{N}';
|
||||
$sym = '[^\p{Lu}\p{Ll}\p{N}]';
|
||||
$pcre = true;
|
||||
}
|
||||
else if (function_exists('mb_ereg_match'))
|
||||
{
|
||||
mb_regex_encoding('UTF-8');
|
||||
$upp = '[[:upper:]]';
|
||||
$low = '[[:lower:]]';
|
||||
$num = '[[:digit:]]';
|
||||
$sym = '[^[:upper:][:lower:][:digit:]]';
|
||||
$mbstring = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1268,6 +1280,7 @@ function validate_password($password)
|
|||
$low = '[a-z]';
|
||||
$num = '[0-9]';
|
||||
$sym = '[^A-Za-z0-9]';
|
||||
$pcre = true;
|
||||
}
|
||||
|
||||
$chars = array();
|
||||
|
@ -1293,6 +1306,8 @@ function validate_password($password)
|
|||
break;
|
||||
}
|
||||
|
||||
if ($pcre)
|
||||
{
|
||||
foreach ($chars as $char)
|
||||
{
|
||||
if (!preg_match('#' . $char . '#u', $password))
|
||||
|
@ -1300,6 +1315,17 @@ function validate_password($password)
|
|||
return 'INVALID_CHARS';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($mbstring)
|
||||
{
|
||||
foreach ($chars as $char)
|
||||
{
|
||||
if (!mb_ereg_match($char, $password))
|
||||
{
|
||||
return 'INVALID_CHARS';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue