Last modified: 2011-11-20 19:55:13 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T28854, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 26854 - Invalid username errors goes unchecked
Invalid username errors goes unchecked
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
User login and signup (Other open bugs)
1.18.x
All All
: Normal minor (vote)
: ---
Assigned To: Nobody - You can work on this!
: need-unittest, patch, patch-need-review
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-21 21:29 UTC by Søren Løvborg
Modified: 2011-11-20 19:55 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Adds checks for invalid usernames. (11.18 KB, patch)
2011-01-21 21:29 UTC, Søren Løvborg
Details

Description Søren Løvborg 2011-01-21 21:29:47 UTC
Created attachment 8017 [details]
Adds checks for invalid usernames.

Note: I encountered this issue on a wiki with very specific rules on username composition. Errors are unlikely (but not impossible) on vanilla installs.

Per the code docs, User::newFromName returns a "User object, or false if the username is invalid (e.g. if it contains illegal characters or is an IP address). If the username is not present in the database, the result will be a user object with a name, zero user ID and default settings." Username validity may, among other things, be constrained by plugins through the AuthPlugin interface.

Due to the creation of "mock" User objects for non-existent users with valid usernames, and since almost any name is valid by default, newFromName rarely returns false on vanilla installs. This explains why a lot of code doesn't handle the case where the result is false.

Note that User::newFromName can return false even when the validate argument is false, as getCanonicalName always performs at least minimal validation (no '#' in names).

In an attempt to fix these errors, I've reviewed all invocations of User::newFromName in r80702.

For maintenance scripts, simply dying with an error message seems reasonable. 

For include files, I've tried to handle invalid usernames appropriately.

For the last 4 files in the attached diff, I'm unsure how to properly handle the error condition. The diff for these files consist only of a FIXME code comment indicating the problem.
Comment 1 Sumana Harihareswara 2011-11-10 02:38:14 UTC
Søren Løvborg, I'm sorry for the wait.  Thanks for the patch.  I'm adding the "need-review" keyword to ask developers to review your patch.  Thanks for contributing.
Comment 2 Roan Kattouw 2011-11-20 11:30:10 UTC
Applied most of the patch in r103745, and fixed SpecialContributions and SpecialDeletedContributions in r103751.
Comment 3 Søren Løvborg 2011-11-20 19:55:13 UTC
Thanks guys, much appreciated.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links