From 7b29f47a8e18818db0c12dd37455a8df64d6835c Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 15 Apr 2010 22:41:49 +0000 Subject: [PATCH] Put a 235 byte limit on usernames to allow /thelongskinname.css to work (bug 23080) --- includes/User.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/includes/User.php b/includes/User.php index 227e36af61..275800f806 100644 --- a/includes/User.php +++ b/includes/User.php @@ -599,20 +599,31 @@ class User { * either by batch processes or by user accounts which have * already been created. * - * Additional character blacklisting may be added here - * rather than in isValidUserName() to avoid disrupting - * existing accounts. + * Additional blacklisting may be added here rather than in + * isValidUserName() to avoid disrupting existing accounts. * * @param $name \string String to match * @return \bool True or false */ static function isCreatableName( $name ) { global $wgInvalidUsernameCharacters; - return - self::isUsableName( $name ) && - // Registration-time character blacklisting... - !preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ); + // Ensure that the username isn't longer than 235 bytes, so that + // (at least for the builtin skins) user javascript and css files + // will work. (bug 23080) + if( strlen( $name ) > 235 ) { + wfDebugLog( 'username', __METHOD__ . + ": '$name' invalid due to length" ); + return false; + } + + if( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) { + wfDebugLog( 'username', __METHOD__ . + ": '$name' invalid due to wgInvalidUsernameCharacters" ); + return false; + } + + return self::isUsableName( $name ); } /** -- 2.20.1