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.