From c75197371c81cfe35b0c29e3cd8ea3219e3a6bd1 Mon Sep 17 00:00:00 2001 From: Ryan Schmidt Date: Tue, 24 Mar 2009 22:36:53 +0000 Subject: [PATCH] * Added $wgInvalidUsernameCharacters to disallow certain characters in usernames during registration (such as "@") * Added $wgUserrightsInterwikiDelimiter to allow changing the delimiter used in Special:UserRights to denote the user should be searched for on a different database --- RELEASE-NOTES | 7 ++++++- includes/DefaultSettings.php | 18 ++++++++++++++++++ includes/User.php | 3 ++- includes/specials/SpecialUserrights.php | 4 ++-- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f32d7a693c..46f7904748 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -149,7 +149,12 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN $wgTiffThumbnailType * Renamed two input IDs on Special:Log from 'page' and 'user' to 'mw-log-page' and 'mw-log-user', respectively - +* Added $wgInvalidUsernameCharacters to disallow certain characters in + usernames during registration (such as "@") +* Added $wgUserrightsInterwikiDelimiter to allow changing the delimiter + used in Special:UserRights to denote the user should be searched for + on a different database + === Bug fixes in 1.15 === * (bug 16968) Special:Upload no longer throws useless warnings. * (bug 17000) Special:RevisionDelete now checks if the database is locked diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index cab5edbadc..ff7acbed08 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -3786,3 +3786,21 @@ $wgUseTagFilter = true; * To enable, set to a string like 'Main Page' */ $wgRedirectOnLogin = null; + +/** + * Characters to prevent during new account creations. + * This is used in a regular expression character class during + * registration (regex metacharacters like / are escaped). + */ +$wgInvalidUsernameCharacters = '@'; + +/** + * Character used as a delimiter when testing for interwiki userrights + * (In Special:UserRights, it is possible to modify users on different + * databases if the delimiter is used, e.g. Someuser@enwiki). + * + * It is recommended that you have this delimiter in + * $wgInvalidUsernameCharacters above, or you will not be able to + * modify the user rights of those users via Special:UserRights + */ +$wgUserrightsInterwikiDelimiter = '@'; \ No newline at end of file diff --git a/includes/User.php b/includes/User.php index fad1fb8db5..78cb5efb21 100644 --- a/includes/User.php +++ b/includes/User.php @@ -589,11 +589,12 @@ class User { * @return \bool True or false */ static function isCreatableName( $name ) { + global $wgInvalidUsernameCharacters; return self::isUsableName( $name ) && // Registration-time character blacklisting... - strpos( $name, '@' ) === false; + !preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, ']/' ) . ']/', $name ); } /** diff --git a/includes/specials/SpecialUserrights.php b/includes/specials/SpecialUserrights.php index 11fc9bdbf3..da98375f9b 100644 --- a/includes/specials/SpecialUserrights.php +++ b/includes/specials/SpecialUserrights.php @@ -253,9 +253,9 @@ class UserrightsPage extends SpecialPage { * @return mixed User, UserRightsProxy, or null */ function fetchUser( $username ) { - global $wgOut, $wgUser; + global $wgOut, $wgUser, $wgUserrightsInterwikiDelimiter; - $parts = explode( '@', $username ); + $parts = explode( $wgUserrightsInterwikiDelimiter, $username ); if( count( $parts ) < 2 ) { $name = trim( $username ); $database = ''; -- 2.20.1