What characters are allowed in titles on Wikimedia Commons?
When you upload a file to Wikimedia Commons with the Upload Wizard, you sometimes get an error about invalid titles:

I’ve seen the other title validation by watching the Network tab in the Safari developer tools, but I don’t see the page making any network requests before it rejects this title.
Instead, it’s inspecting the wgIllegalFileChars
setting.
Debugging steps
In the Sources tab of the Safari developer tools, I did a global search (⇧⌘F) for the text in the error. There were two results: once in the HTML of the page where it was appearing, once in a list of error message translations. It’s the English translation for the error mwe-upwiz-error-title-invalid
.

Then I did a search for the ID in the translation file, where I see that you can get this error if an exception is thrown while constructing the title. I made a guess that the makeTitleInFileNS
function might be interesting:

I did another search to find the definition of the function, where I see that it looks for characters defined by a config setting:

And doing one more search, I can find the value of the config setting:

Looking up the name of that config setting (wgIllegalFileChars
) led me to a page in the MediaWiki documentation which describes the behaviour in more detail.
Looking back, I’m not sure I quite followed the right path. I don’t think makeTitleInFileNS
throws an exception; instead, it sets the title to null
if it contains illegal characters. There’s another place you can get the mwe-upwiz-error-title-invalid
error if the title is empty, but it’s less obvious what’s setting the title in this context:
