Trim whitespace before checking if the nick is valid

This was reported as https://bugzilla.wikimedia.org/show_bug.cgi?id=49542