Simplify checks on Special:UserLogin/signup
authorumherirrender <umherirrender_de.wp@web.de>
Mon, 25 Aug 2014 18:12:27 +0000 (20:12 +0200)
committerReedy <reedy@wikimedia.org>
Sat, 15 Nov 2014 20:57:36 +0000 (20:57 +0000)
I27c488e4008a924117ff6bac2216f148cd5e7abd changed the validation code in
User::getCanonicalName, the # and Title::makeTitleSafe checks now done
there and can be removed here.

Follow-Up: I27c488e4008a924117ff6bac2216f148cd5e7abd
Follow-Up: I88c479cea2bc9d2eab882e0ee8ebcbe2d1dd125e
Follow-Up: I983e3f528491817f9f31f71a92d8d2946ce5941d
Change-Id: I17bf88be6398dc402295264ca9bfd57809c872d7

includes/specials/SpecialUserlogin.php

index b6a3be2..2eefd0a 100644 (file)
@@ -527,20 +527,8 @@ class LoginForm extends SpecialPage {
                        return Status::newFatal( 'sorbs_create_account_reason' );
                }
 
-               // Normalize the name so that silly things don't cause "invalid username"
-               // errors. User::newFromName does some rather strict checking, rejecting
-               // e.g. leading/trailing/multiple spaces. But first we need to reject
-               // usernames that would be treated as titles with a fragment part.
-               if ( strpos( $this->mUsername, '#' ) !== false ) {
-                       return Status::newFatal( 'noname' );
-               }
-               $title = Title::makeTitleSafe( NS_USER, $this->mUsername );
-               if ( !is_object( $title ) ) {
-                       return Status::newFatal( 'noname' );
-               }
-
                # Now create a dummy user ($u) and check if it is valid
-               $u = User::newFromName( $title->getText(), 'creatable' );
+               $u = User::newFromName( $this->mUsername, 'creatable' );
                if ( !is_object( $u ) ) {
                        return Status::newFatal( 'noname' );
                } elseif ( 0 != $u->idForName() ) {