Commit 59b94f06 authored by drumm's avatar drumm
Browse files

#102170 by ChrisKennedy. Make username and email field #maxlengths consistent.

parent 2fe0e80f
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
* Enables the user registration and login system. * Enables the user registration and login system.
*/ */
define('USERNAME_MAX_LENGTH', 60);
define('EMAIL_MAX_LENGTH', 64);
/** /**
* Invokes hook_user() in every module. * Invokes hook_user() in every module.
* *
...@@ -254,7 +257,7 @@ function user_validate_name($name) { ...@@ -254,7 +257,7 @@ function user_validate_name($name) {
return t('The username contains an illegal character.'); return t('The username contains an illegal character.');
} }
if (ereg('@', $name) && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.'); if (ereg('@', $name) && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.');
if (strlen($name) > 56) return t('The username %name is too long: it must be less than 56 characters.', array('%name' => $name)); if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
} }
function user_validate_mail($mail) { function user_validate_mail($mail) {
...@@ -477,7 +480,7 @@ function user_login_block() { ...@@ -477,7 +480,7 @@ function user_login_block() {
); );
$form['name'] = array('#type' => 'textfield', $form['name'] = array('#type' => 'textfield',
'#title' => t('Username'), '#title' => t('Username'),
'#maxlength' => 60, '#maxlength' => USERNAME_MAX_LENGTH,
'#size' => 15, '#size' => 15,
'#required' => TRUE, '#required' => TRUE,
); );
...@@ -891,7 +894,7 @@ function user_login($msg = '') { ...@@ -891,7 +894,7 @@ function user_login($msg = '') {
$form['name'] = array('#type' => 'textfield', $form['name'] = array('#type' => 'textfield',
'#title' => t('Username'), '#title' => t('Username'),
'#size' => 30, '#size' => 30,
'#maxlength' => 60, '#maxlength' => USERNAME_MAX_LENGTH,
'#required' => TRUE, '#required' => TRUE,
'#attributes' => array('tabindex' => '1'), '#attributes' => array('tabindex' => '1'),
); );
...@@ -1028,7 +1031,7 @@ function user_pass() { ...@@ -1028,7 +1031,7 @@ function user_pass() {
$form['name'] = array('#type' => 'textfield', $form['name'] = array('#type' => 'textfield',
'#title' => t('Username or e-mail address'), '#title' => t('Username or e-mail address'),
'#size' => 30, '#size' => 30,
'#maxlength' => 60, '#maxlength' => max(USERNAME_MAX_LENGTH, EMAIL_MAX_LENGTH),
'#required' => TRUE, '#required' => TRUE,
); );
$form['submit'] = array('#type' => 'submit', $form['submit'] = array('#type' => 'submit',
...@@ -1294,7 +1297,7 @@ function user_edit_form($uid, $edit, $register = FALSE) { ...@@ -1294,7 +1297,7 @@ function user_edit_form($uid, $edit, $register = FALSE) {
$form['account']['name'] = array('#type' => 'textfield', $form['account']['name'] = array('#type' => 'textfield',
'#title' => t('Username'), '#title' => t('Username'),
'#default_value' => $edit['name'], '#default_value' => $edit['name'],
'#maxlength' => 60, '#maxlength' => USERNAME_MAX_LENGTH,
'#description' => t('Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores.'), '#description' => t('Your preferred username; punctuation is not allowed except for periods, hyphens, and underscores.'),
'#required' => TRUE, '#required' => TRUE,
); );
...@@ -1302,7 +1305,7 @@ function user_edit_form($uid, $edit, $register = FALSE) { ...@@ -1302,7 +1305,7 @@ function user_edit_form($uid, $edit, $register = FALSE) {
$form['account']['mail'] = array('#type' => 'textfield', $form['account']['mail'] = array('#type' => 'textfield',
'#title' => t('E-mail address'), '#title' => t('E-mail address'),
'#default_value' => $edit['mail'], '#default_value' => $edit['mail'],
'#maxlength' => 64, '#maxlength' => EMAIL_MAX_LENGTH,
'#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'), '#description' => t('A valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.'),
'#required' => TRUE, '#required' => TRUE,
); );
...@@ -1551,7 +1554,7 @@ function _user_mail_text($messageid, $variables = array()) { ...@@ -1551,7 +1554,7 @@ function _user_mail_text($messageid, $variables = array()) {
function user_admin_check_user() { function user_admin_check_user() {
$form['user'] = array('#type' => 'fieldset', '#title' => t('Username')); $form['user'] = array('#type' => 'fieldset', '#title' => t('Username'));
$form['user']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a username to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64); $form['user']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter a username to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => USERNAME_MAX_LENGTH);
$form['user']['type'] = array('#type' => 'hidden', '#value' => 'user'); $form['user']['type'] = array('#type' => 'hidden', '#value' => 'user');
$form['user']['submit'] = array('#type' => 'submit', '#value' => t('Check username')); $form['user']['submit'] = array('#type' => 'submit', '#value' => t('Check username'));
$form['#base'] = 'user_admin_access_check'; $form['#base'] = 'user_admin_access_check';
...@@ -1560,7 +1563,7 @@ function user_admin_check_user() { ...@@ -1560,7 +1563,7 @@ function user_admin_check_user() {
function user_admin_check_mail() { function user_admin_check_mail() {
$form['mail'] = array('#type' => 'fieldset', '#title' => t('E-mail')); $form['mail'] = array('#type' => 'fieldset', '#title' => t('E-mail'));
$form['mail']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter an e-mail address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => 64); $form['mail']['test'] = array('#type' => 'textfield', '#title' => '', '#description' => t('Enter an e-mail address to check if it will be denied or allowed.'), '#size' => 30, '#maxlength' => EMAIL_MAX_LENGTH);
$form['mail']['type'] = array('#type' => 'hidden', '#value' => 'mail'); $form['mail']['type'] = array('#type' => 'hidden', '#value' => 'mail');
$form['mail']['submit'] = array('#type' => 'submit', '#value' => t('Check e-mail')); $form['mail']['submit'] = array('#type' => 'submit', '#value' => t('Check e-mail'));
$form['#base'] = 'user_admin_access_check'; $form['#base'] = 'user_admin_access_check';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment