* (bug 2629) Automatically capitalize usernames again instead of
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 1 Jul 2005 21:47:23 +0000 (21:47 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 1 Jul 2005 21:47:23 +0000 (21:47 +0000)
  rejecting lowercase with a useless error message

RELEASE-NOTES
includes/SpecialUserlogin.php
includes/User.php

index b215a10..94f254b 100644 (file)
@@ -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 ===
 
index 953e3c9..b392a38 100644 (file)
@@ -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;
                }
index 2a7a9b5..edf98ef 100644 (file)
@@ -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;