+ $password = trim($password);
+
+ if (empty($password)) {
+ throw new Exception(L10n::t('Empty passwords are not allowed.'));
+ }
+
+ if (!Config::get('system', 'disable_password_exposed', false) && self::isPasswordExposed($password)) {
+ throw new Exception(L10n::t('The new password has been exposed in a public data dump, please choose another.'));
+ }
+
+ $allowed_characters = '!"#$%&\'()*+,-./;<=>?@[\]^_`{|}~';
+
+ if (!preg_match('/^[a-z0-9' . preg_quote($allowed_characters, '/') . ']+$/i', $password)) {
+ throw new Exception(L10n::t('The password can\'t contain accentuated letters, white spaces or colons (:)'));
+ }
+