Skip to content

Commit

Permalink
Allow hyphens and spaces in usernames and put the regex used to valid…
Browse files Browse the repository at this point in the history
…ate them in a config option.

* config_defaults_inc.php
  (user_login_valid_regex): new option giving a regex to use for validating
    new login names

* core/user_api.php
  (user_is_name_valid): use new config option (user_login_valid_regex) for
    regular expression

* lang/strings_english.txt
  (ERROR_USER_NAME_INVALID): add a sentence describing what the user name
    limitations are


git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@2160 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
Julian Fitzell committed Apr 23, 2003
1 parent cd22e09 commit 3aff271
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
9 changes: 8 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: config_defaults_inc.php,v 1.117 2003-03-27 22:34:04 int2str Exp $
# $Id: config_defaults_inc.php,v 1.118 2003-04-23 19:32:39 jfitzell Exp $
# --------------------------------------------------------


Expand Down Expand Up @@ -718,6 +718,13 @@
# This is useful for installations where assigned status is to be used when
# the bug is in progress, rather than just put in a person's queue.
$g_auto_set_status_to_assigned = ON;

# The regular expression to use when validating new user login names
# The default regular expression allows a-z, A-z, 0-9, as well as space and
# underscore. If you change this, you may want to update the
# ERROR_USER_NAME_INVALID string in the language files to explain
# the rules you are using on your site
$g_user_login_valid_regex = '/^[\w \-]+$/';

################################
# Mantis Look and Feel Variables
Expand Down
4 changes: 2 additions & 2 deletions core/user_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: user_api.php,v 1.57 2003-04-06 23:43:10 vboctor Exp $
# $Id: user_api.php,v 1.58 2003-04-23 19:32:40 jfitzell Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -148,7 +148,7 @@ function user_is_name_valid( $p_username ) {
}

# Only allow a basic set of characters
if ( 0 == preg_match( '/^\w+$/', $p_username ) ) {
if ( 0 == preg_match( config_get( 'user_login_valid_regex' ), $p_username ) ) {
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions doc/ChangeLog
Expand Up @@ -3,7 +3,9 @@ Mantis ChangeLog
2003.??.?? - 0.18.0a5

* Enhancement: Show file attachment indicator on bug list page (#3088).
* New config option(user_login_valid_regex): regular expression used to validate new login names
* Fix: Improved adherance to the XHTML standard.
* Fix: Allow spaces and hyphens in emails
* Fix #2992: Unable to attach files to bugs on Windows servers with magic quotes ON.
* Fix #3027: History summary a little bit too wide in emails.
* Fix #3064: view bug buttons in vertical column
Expand Down
10 changes: 5 additions & 5 deletions lang/strings_english.txt
Expand Up @@ -9,11 +9,11 @@
###########################################################################
# English strings for Mantis
# -------------------------------------------------
# $Revision: 1.132 $
# $Author: int2str $
# $Date: 2003-03-31 22:21:06 $
# $Revision: 1.133 $
# $Author: jfitzell $
# $Date: 2003-04-23 19:32:42 $
#
# $Id: strings_english.txt,v 1.132 2003-03-31 22:21:06 int2str Exp $
# $Id: strings_english.txt,v 1.133 2003-04-23 19:32:42 jfitzell Exp $
###########################################################################
?>
<?php
Expand Down Expand Up @@ -196,7 +196,7 @@
$MANTIS_ERROR[ERROR_CATEGORY_NOT_FOUND] = 'ERROR: Category not found.';
$MANTIS_ERROR[ERROR_VERSION_DUPLICATE] = 'ERROR: A version with that name already exists.';
$MANTIS_ERROR[ERROR_VERSION_NOT_FOUND] = 'ERROR: Version not found.';
$MANTIS_ERROR[ERROR_USER_NAME_INVALID] = 'ERROR: The username is invalid.';
$MANTIS_ERROR[ERROR_USER_NAME_INVALID] = 'ERROR: The username is invalid. Usernames may only contain letters, numbers, spaces, hyphens, and underscores.';

$s_login_error = 'ERROR: your account may be disabled or the username/password you entered is incorrect.';
$s_login_cookies_disabled = 'ERROR: Your browser either doesn\'t know how to handle cookies, or refuses to handle them.';
Expand Down

0 comments on commit 3aff271

Please sign in to comment.