From 74fd7962bfb9c0dc6a44f9027ee10ff88e6a6536 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 1 Jul 2005 21:47:23 +0000 Subject: [PATCH] * (bug 2629) Automatically capitalize usernames again instead of rejecting lowercase with a useless error message --- RELEASE-NOTES | 3 +++ includes/SpecialUserlogin.php | 2 +- includes/User.php | 25 ++++++++++++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b215a101a3..94f254bcd7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -440,6 +440,9 @@ Various bugfixes, small features, and a few experimental things: * (bug 2609) Fix text justification preferenced with MonoBook skin. * (bug 2594) Display article tab as red for non-existent articles. * (bug 2656) Fix regression: prevent blocked users from reverting images +* (bug 2629) Automatically capitalize usernames again instead of + rejecting lowercase with a useless error message + === Caveats === diff --git a/includes/SpecialUserlogin.php b/includes/SpecialUserlogin.php index 953e3c9d11..b392a385df 100644 --- a/includes/SpecialUserlogin.php +++ b/includes/SpecialUserlogin.php @@ -202,7 +202,7 @@ class LoginForm { $name = trim( $this->mName ); $u = User::newFromName( $name ); - if ( is_null( $u ) || !$wgUser->isValidUserName( $name ) ) { + if ( is_null( $u ) ) { $this->mainLoginForm( wfMsg( 'noname' ) ); return false; } diff --git a/includes/User.php b/includes/User.php index 2a7a9b5081..edf98ef2a1 100644 --- a/includes/User.php +++ b/includes/User.php @@ -52,16 +52,25 @@ class User { function newFromName( $name ) { $u = new User(); + # Force usernames to capital + global $wgContLang; + $name = $wgContLang->ucfirst( $name ); + # Clean up name according to title rules - $t = Title::newFromText( $name ); if( is_null( $t ) ) { - return NULL; - } else { - $u->setName( $t->getText() ); - $u->setId( $u->idFromName( $t->getText() ) ); - return $u; + return null; } + + # Reject various classes of invalid names + $canonicalName = $t->getText(); + if( !User::isValidUserName( $canonicalName ) ) { + return null; + } + + $u->setName( $canonicalName ); + $u->setId( $u->idFromName( $t->getText() ) ); + return $u; } /** @@ -172,12 +181,13 @@ class User { * * @param string $name * @return bool + * @static */ function isValidUserName( $name ) { global $wgContLang, $wgMaxNameChars; if ( $name == '' - || $this->isIP( $name ) + || User::isIP( $name ) || strpos( $name, '/' ) !== false || strlen( $name ) > $wgMaxNameChars || $name != $wgContLang->ucfirst( $name ) ) @@ -191,6 +201,7 @@ class User { * * @param string $password * @return bool + * @static */ function isValidPassword( $password ) { global $wgMinimalPasswordLength; -- 2.20.1