Page MenuHomePhabricator

Special:ListFiles shows usernames with underscores
Closed, ResolvedPublic

Description

See https://commons.wikimedia.org/w/index.php?title=Special:ListFiles/Mat%C4%9Bj_Such%C3%A1nek&uselang=en.
My username includes a space but an underscore is shown.

Instructions:
The page title is set in SpecialListFiles::execute in mediawiki/core repository.
The variable $userName should probably be sanitized by User::getCanonicalName.

Event Timeline

I would like to work on this task.

@matej_suchanek Thanks for the reference. Once I set up the environment, I'll start working.

Change 571681 had a related patch set uploaded (by Sahajsk; owner: Sahajsk):
[mediawiki/core@master] Fix::Special:ListFiles shows usernames with underscores

https://gerrit.wikimedia.org/r/571681

@matej_suchanek Can you help me with the cases when getCanonicalName return false? Also does the initial code handle the case of invalid username.

Sure.

@thiemowmde pointed out User::getCanonicalName does validation by default. We can avoid validation by setting the second argument to false.

$userName = User::getCanonicalName( $temp_userName , false );
I have changed the statement to something like this.
Also should the condition to check if getCanonicalName returns false be removed or kept.

Thanks for the update. Unfortunately I can not see it yet on the patch https://gerrit.wikimedia.org/r/571681.

The check for false needs to stay, because there is still a chance it can return false, even without full validation.

Change 571681 merged by jenkins-bot:
[mediawiki/core@master] Make Special:ListFiles not show usernames with underscores

https://gerrit.wikimedia.org/r/571681