SpecialUserlogin: Error out when attempting to create a username with a '#'
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 9 May 2014 22:44:05 +0000 (00:44 +0200)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 9 May 2014 22:44:05 +0000 (00:44 +0200)
"Best practices"? Ain't never heard of it.

Bug: 64960
Change-Id: I88c479cea2bc9d2eab882e0ee8ebcbe2d1dd125e

includes/specials/SpecialUserlogin.php

index 4006e49..5ce2812 100644 (file)
@@ -435,7 +435,11 @@ class LoginForm extends SpecialPage {
 
                // 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.
+               // 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' );