diff --git a/config.inc.php b/config.inc.php index 12784c10..34b2e291 100644 --- a/config.inc.php +++ b/config.inc.php @@ -240,7 +240,7 @@ $CONF['password_validation'] = array( '/.{5}/' => 'password_too_short 5', # minimum length 5 characters '/([a-zA-Z].*){3}/' => 'password_no_characters 3', # must contain at least 3 characters '/([0-9].*){2}/' => 'password_no_digits 2', # must contain at least 2 digits -# '/([!\".,*&^%$£)(_+=\-`\'#@~\[\]\\<>\/].*){1}/' => 'password_no_special 1', # must contain at least 1 special character +# '/([!\".,*&^%$£)(_+=\-`\'#@~\[\]\\<>\/].*){1,}/' => 'password_no_special 1', # must contain at least 1 special character /* support a 'callable' value which if it returns a non-empty string will be assumed to have failed, non-empty string should be a PALANG key */ // 'length_check' => function($password) { if (strlen(trim($password)) < 3) { return 'password_too_short'; } }, diff --git a/tests/ValidatePasswordTest.php b/tests/ValidatePasswordTest.php index de9f2a44..61f151b7 100644 --- a/tests/ValidatePasswordTest.php +++ b/tests/ValidatePasswordTest.php @@ -27,12 +27,13 @@ class ValidatePasswordTest extends \PHPUnit\Framework\TestCase // Set to the defaults, just to make sure. Config::write('password_validation', array( - '/([!\".,*&^%$£)(_+=\-`\'#@~\[\]\\<>\/].*){2}/' => 'password_no_special 1', # must contain at least 1 special character + '/([!\".,*&^%$£)(_+=\-`\'#@~\[\]\\<>\/].*){1,}/' => 'password_no_special 1', # must contain at least 1 special character )); $this->assertEmpty(validate_password('fish^Sh$$p01')); $this->assertEmpty(validate_password(']/>')); - $this->assertEmpty(validate_password("P'55w\ord")); - $this->assertNotEmpty(validate_password("fish'Sheep01")); + $this->assertEmpty(validate_password("P'55w\\ord")); + $this->assertEmpty(validate_password("P'55word"), "should contain 1 special char"); + $this->assertNotEmpty(validate_password("fishSheep01"), "does not contain any special chars..."); } }