Last modified: 2014-05-18 14:30:08 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 T66960, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 64960 - Attempting to create a username with a hash in should throw an error
Attempting to create a username with a hash in should throw an error
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
User login and signup (Other open bugs)
unspecified
All All
: Normal minor (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: hackathon2014
  Show dependency treegraph
 
Reported: 2014-05-06 18:08 UTC by Dan Garry
Modified: 2014-05-18 14:30 UTC (History)
6 users (show)

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


Attachments

Description Dan Garry 2014-05-06 18:08:32 UTC
If you're on desktop with JS enabled and ignore the error-like warning [1] presented to you when you try to create a username with a hash in, everything including and after the hash is silently truncated from the username. This means the user ends up creating a username that is different from what they typed in, which is suboptimal from a product perspective.

It should simply not be possible to create such usernames, and there should be an error presented to the user if they try.

[1]: It's not actually an error, it's just styled exactly like one in the user interface, probably to disincline people from trying to create it.
Comment 1 Liangent 2014-05-06 18:16:16 UTC
(In reply to Dan Garry from comment #0)
> This means the user ends up creating a username that is different
> from what they typed in, which is suboptimal from a product perspective.

Truncation is just a part of username normalization. Some other parts including making the first character uppercase and replace underscores with spaces. There're still other cases where "the user ends up creating a username that is different from what they typed in".

And in practice, I saw some rename requests about 'I tried to create "foobar" but the system gave me "Foobar" but I still want "foobar".' and after rejection due to 'technical restrictions' they turn to say 'Then give me "FOOBAR" please'.
Comment 2 Dan Garry 2014-05-06 18:27:15 UTC
(In reply to Liangent from comment #1)
> (In reply to Dan Garry from comment #0)
> > This means the user ends up creating a username that is different
> > from what they typed in, which is suboptimal from a product perspective.
> 
> Truncation is just a part of username normalization. Some other parts
> including making the first character uppercase and replace underscores with
> spaces. There're still other cases where "the user ends up creating a
> username that is different from what they typed in".

These other cases you mentioned are a bit different though: trying to log in with the username you typed in (e.g. "dGarry (WMF)" rather than "DGarry_(WMF)") will still work, as will typing any of these variants as a URL to find the person's userpage. Neither of these are true of the username containing the hashes.

The case with the hash is the low-hanging fruit; it's one bit where the user experience is particularly confusing, and there is a clear solution for fixing it.
Comment 3 Liangent 2014-05-06 18:40:02 UTC
Well using a user name with extra #foobar works in wikilinks and URL: #foobar is just considered page fragment.

I guess it's the just the cause of this bug that "#" starts a fragment: they use class Title to normalize user names and #foobar is split out after being parsed.
Comment 4 Umherirrender 2014-05-06 18:48:47 UTC
Possible caused by Gerrit change #115329 where a Title call was added
Comment 5 Bartosz Dziewoński 2014-05-06 20:23:42 UTC
(In reply to Liangent from comment #1)
> And in practice, I saw some rename requests about 'I tried to create
> "foobar" but the system gave me "Foobar" but I still want "foobar".' and
> after rejection due to 'technical restrictions' they turn to say 'Then give
> me "FOOBAR" please'.

This is bug 61416 and the associated patch If60219a1 which needs love.
Comment 6 Bartosz Dziewoński 2014-05-06 20:31:17 UTC
(In reply to Umherirrender from comment #4)
> Possible caused by Gerrit change #115329 where a Title call was added

Ugh, sounds likely. We should probably check the the object returned by Title::makeTitleSafe() is in the User: namespace and has no interwiki or fragment parts. (We should also probably make this a separate methods and add tests.)
Comment 7 Umherirrender 2014-05-07 17:28:13 UTC
(In reply to Bartosz Dziewoński from comment #6)
> (In reply to Umherirrender from comment #4)
> > Possible caused by Gerrit change #115329 where a Title call was added
> 
> Ugh, sounds likely. We should probably check the the object returned by
> Title::makeTitleSafe() is in the User: namespace and has no interwiki or
> fragment parts. (We should also probably make this a separate methods and
> add tests.)

I am not sure, but that sounds like User::getCanonicalName (which also handles the # part), which gets called by User::newFromName, but due to Gerrit change #115329 there seems a problem with that, but I cannot see the problem at the moment.

Title::makeTitleSafe here will you give always a title in User namespace and without a interwiki or null, if that is not possible. By using Title::newFromText you have to check that, because there the given title can override the default namespace. With makeTitleSafe it should be impossible to do that.
Comment 8 Bartosz Dziewoński 2014-05-09 22:20:35 UTC
User::getCanonicalName( …, 'creatable' ) (or User::isCreatableName( … ) that calls internally) is very strict and will reject, for example, a username like "User " (with a *trailing space*).
Comment 9 Bartosz Dziewoński 2014-05-09 22:37:54 UTC
Actually, we can't even check for the fragment reliably, because "User:Foo#" (trailing hash sign) will be considered as having no fragment part.

I say we just explicitly check for a '#' in text there and call it a day.
I'm afraid to change the behavior of User::getCanonicalName() unless somebody
who knows more about how these things work verifies whatever I'd write.


(In reply to Umherirrender from comment #7)
> Title::makeTitleSafe here will you give always a title in User namespace and
> without a interwiki or null, if that is not possible. By using
> Title::newFromText you have to check that, because there the given title can
> override the default namespace. With makeTitleSafe it should be impossible
> to do that.

Yeah, you're right of course.
Comment 10 Gerrit Notification Bot 2014-05-09 22:44:21 UTC
Change 132584 had a related patch set uploaded by Bartosz Dziewoński:
SpecialUserlogin: Error out when attempting to create a username with a '#'

https://gerrit.wikimedia.org/r/132584
Comment 11 Dan Garry 2014-05-09 23:09:27 UTC
Thanks for working on this Bartosz! I'll try to get an engineer to review your patch.
Comment 12 Gerrit Notification Bot 2014-05-09 23:14:31 UTC
Change 132584 merged by Brion VIBBER:
SpecialUserlogin: Error out when attempting to create a username with a '#'

https://gerrit.wikimedia.org/r/132584
Comment 13 Bartosz Dziewoński 2014-05-09 23:28:33 UTC
I guess this should be fixed now. I'm not happy with the solution, though :(
Comment 14 Yuvi Panda 2014-05-18 14:30:08 UTC
Thanks for the patch MatmaRex!

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


Navigation
Links