From: Chad Horohoe Date: Wed, 9 Feb 2011 13:42:02 +0000 (+0000) Subject: preg_match() yells about undefined offsets when $wgInvalidUsernameCharacters is empty... X-Git-Tag: 1.31.0-rc.0~32098 X-Git-Url: http://git.cyclocoop.org/data/%24oldEdit?a=commitdiff_plain;h=670b92b065c2c9ed93e29dea66e8a3d42f540f9d;p=lhc%2Fweb%2Fwiklou.git preg_match() yells about undefined offsets when $wgInvalidUsernameCharacters is empty. Noticed by wolog on IRC --- diff --git a/includes/User.php b/includes/User.php index 834c770f06..0f9d9738f3 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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 );