From 670b92b065c2c9ed93e29dea66e8a3d42f540f9d Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 9 Feb 2011 13:42:02 +0000 Subject: [PATCH] preg_match() yells about undefined offsets when $wgInvalidUsernameCharacters is empty. Noticed by wolog on IRC --- includes/User.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 ); -- 2.20.1