logintoboggan_validate_pass

  1. drupal
    1. 6 logintoboggan.module function
    2. 7 logintoboggan.module function
Drupal 7 logintoboggan_validate_pass($pass)

Modified version of user_validate_name

  • validates user submitted passwords have a certain length and only contain letters, numbers or punctuation (graph character class in regex)

2 calls to logintoboggan_validate_pass()

File

sites/all/modules/logintoboggan/logintoboggan.module, line 950
LoginToboggan module

Code

function logintoboggan_validate_pass($pass) {
  if (!strlen($pass)) {
    return t('You must enter a password.');
  }
  if (preg_match('/[\x{80}-\x{A0}' .          // Non-printable ISO-8859-1 + NBSP
                   '\x{A1}-\x{F7}' .          // Latin punctuations
                   '\x{AD}' .                 // Soft-hyphen
                   '\x{2000}-\x{200F}' .      // Various space characters
                   '\x{2028}-\x{202F}' .      // Bidirectional text overrides
                   '\x{205F}-\x{206F}' .      // Various text hinting characters
                   '\x{FEFF}' .               // Byte order mark
                   '\x{FF01}-\x{FF60}' .      // Full-width latin
                   '\x{FFF9}-\x{FFFD}]/u',    // Replacement characters
                   $pass)) {
    return t('The password contains an illegal character.');
  }
  $min_pass_length = variable_get('logintoboggan_minimum_password_length', 0);
  if ($min_pass_length && strlen($pass) < $min_pass_length) {
    return t("The password is too short: it must be at least %min_length characters.", array('%min_length' => $min_pass_length));
  }
}