Trimming usernames - by design or an oversight?

We've noticed recently an issue where users are copying and pasting usernames from an email, and picking up a trailing space when they do it. Matrix attempts to authenticate with the space on the end of the username, and fails.


Most other systems I know run the username (and often the password) through trim() before attempting to authenticate against them. Is this behaviour intentional in Matrix, or is it an oversight? If its an oversight, I'll happily log it as a feature request.

[quote]
We've noticed recently an issue where users are copying and pasting usernames from an email, and picking up a trailing space when they do it. Matrix attempts to authenticate with the space on the end of the username, and fails.



Most other systems I know run the username (and often the password) through trim() before attempting to authenticate against them. Is this behaviour intentional in Matrix, or is it an oversight? If its an oversight, I'll happily log it as a feature request.

[/quote]





See



http://bugs.matrix.squiz.net/view_bug.php?bug_id=4040

[quote]
See

http://bugs.matrix.squiz.net/view_bug.php?bug_id=4040

[/quote]

We will consider this under funded development.



My comment on the Feature Request mentions not extending this to passwords, however this could be implemented as a switch on System Configuration which would default to not stripping spaces. The option will strip leading and trailing whitespace (spaces and tabs) from both username and password fields in one option, prior to authentication.



I will update the request details with this information.

Hey Peter, we've had a very similar issue with people copying and pasting spaces and have found a solution which might be of use to you and will avoid any custom development, waiting, et al.


What we did is essentially strip out whitespace with jQuery from the SQ_LOGIN_USERNAME input field on the fly.



In your login design parse file place the following code at the bottom of your page (remember to include the newest version of jQuery too!).


    
    




What this does is snatch any spaces and remove them. The .blur function makes it work with copy and paste too which is where the majority of situations where this error was occurring for me.



The issue is if you allow people to have spaces in their username as it’ll strip every space. We don’t allow spaces in the username in our system. In fact, you can use the same jquery code to enforce this on your signup page. All you’ll have to do is find the id of the input field which is the unique input field. Something like “backend_user_0_224”.



I hope this helps you. Feel free to use it if it works for you and let me know if you have any problems.



EDIT: Here is a working example I knocked up for you - http://community.squiz.net/demo/loginspaces