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.
+ $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
- $name = trim( $this->mUsername );
- $u = User::newFromName( $name, 'creatable' );
+ $u = User::newFromName( $title->getText(), 'creatable' );
if ( !is_object( $u ) ) {
return Status::newFatal( 'noname' );
} elseif ( 0 != $u->idForName() ) {