preg_match() yells about undefined offsets when $wgInvalidUsernameCharacters is empty...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 9 Feb 2011 13:42:02 +0000 (13:42 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 9 Feb 2011 13:42:02 +0000 (13:42 +0000)
includes/User.php

index 834c770..0f9d973 100644 (file)
@@ -585,10 +585,13 @@ class User {
                        return false;
                }
 
-               if( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
-                       wfDebugLog( 'username', __METHOD__ .
-                               ": '$name' invalid due to wgInvalidUsernameCharacters" );
-                       return false;
+               // Preg yells if you try to give it an empty string
+               if( $wgInvalidUsernameCharacters ) {
+                       if( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
+                               wfDebugLog( 'username', __METHOD__ .
+                                       ": '$name' invalid due to wgInvalidUsernameCharacters" );
+                               return false;
+                       }
                }
 
                return self::isUsableName( $name );