Skip to content

Commit c838aa3

Browse files
author
David Coutadeur
committed
escape forbidden chars (#83)
1 parent 47df997 commit c838aa3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Ltb/Ppolicy.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ static function check_password_strength( $password,
5151

5252
$forbidden = 0;
5353
if ( isset($pwd_forbidden_chars) && !empty($pwd_forbidden_chars) ) {
54-
preg_match_all("/[$pwd_forbidden_chars]/", $password, $forbidden_res);
55-
$forbidden = count( $forbidden_res[0] );
54+
$escaped = preg_quote($pwd_forbidden_chars, '/');
55+
$pattern = '/[' . $escaped . ']/u';
56+
preg_match_all($pattern, $password, $forbidden_res);
57+
$forbidden = isset($forbidden_res[0]) ? count($forbidden_res[0]) : 0;
5658
}
5759

5860
# Complexity: checks for lower, upper, special, digits

0 commit comments

Comments
 (0)