r81812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81811‎ | r81812 | r81813 >
Date:13:42, 9 February 2011
Author:demon
Status:ok (Comments)
Tags:
Comment:
preg_match() yells about undefined offsets when $wgInvalidUsernameCharacters is empty. Noticed by wolog on IRC
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/User.php
@@ -585,10 +585,13 @@
586586 return false;
587587 }
588588
589 - if( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
590 - wfDebugLog( 'username', __METHOD__ .
591 - ": '$name' invalid due to wgInvalidUsernameCharacters" );
592 - return false;
 589+ // Preg yells if you try to give it an empty string
 590+ if( $wgInvalidUsernameCharacters ) {
 591+ if( preg_match( '/[' . preg_quote( $wgInvalidUsernameCharacters, '/' ) . ']/', $name ) ) {
 592+ wfDebugLog( 'username', __METHOD__ .
 593+ ": '$name' invalid due to wgInvalidUsernameCharacters" );
 594+ return false;
 595+ }
593596 }
594597
595598 return self::isUsableName( $name );

Follow-up revisions

RevisionCommit summaryAuthorDate
r81814Followup r81812: per CR, this could be 0demon14:59, 9 February 2011
r85148MFT: r80495, r80610, r80765, r81177, r81490, r81692, r81707, r81729, r81765, ...demon20:11, 1 April 2011

Comments

#Comment by 😂 (talk | contribs)   13:47, 9 February 2011

Not necessary for deployment, but would be nice to sneak this into the general release since it's throws a PHP error.

#Comment by Nikerabbit (talk | contribs)   14:58, 9 February 2011

What if $wgInvalidUsernameCharacters = "0";?

#Comment by 😂 (talk | contribs)   14:59, 9 February 2011

Fixed in the followup.

#Comment by MaxSem (talk | contribs)   11:48, 10 February 2011

Why nested ifs instead of if ( cond1 && cond2 )?

Status & tagging log