Commit 2208a878 authored by Fatih Acet's avatar Fatih Acet

Merge branch 'trim-new-user' into 'master'

Ensure that whitespace doesn't cause adding members to fail

I recently had to debug an issue where adding users wasn't working. It turned out that I was hitting "space" to confirm a `select2` dialog, and the server would throw out the whole email address because it was invalid. It looked as though GitLab was entirely ignoring my add-member request.

Here's a fun gif:
![out](/uploads/5c306addb764067bca54add3b7a53c6c/out.gif)

Ideally, there should also be validation client-side, so that the server doesn't need to silently fail, and the user will know what's going wrong. I'll look into creating an issue for that.

Additionally, GitLab already seems to trim email addresses, sometimes? If you add _two_ address, with spaces, then the `value` of the `user_ids` DOM element will have the first `n-1` addresses without spaces. Weird.

**TL;DR: Now spaces are always trimmed from new-member email addresses.**

See merge request !3443
parents a053430e f19766a3
...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.13.0 (unreleased) v 8.13.0 (unreleased)
- Respond with 404 Not Found for non-existent tags (Linus Thiel) - Respond with 404 Not Found for non-existent tags (Linus Thiel)
- Truncate long labels with ellipsis in labels page - Truncate long labels with ellipsis in labels page
- Adding members no longer silently fails when there is extra whitespace
- Update runner version only when updating contacted_at - Update runner version only when updating contacted_at
- Add link from system note to compare with previous version - Add link from system note to compare with previous version
- Use gitlab-shell v3.6.6 - Use gitlab-shell v3.6.6
......
...@@ -261,10 +261,11 @@ ...@@ -261,10 +261,11 @@
} }
} }
if (showEmailUser && data.results.length === 0 && query.term.match(/^[^@]+@[^@]+$/)) { if (showEmailUser && data.results.length === 0 && query.term.match(/^[^@]+@[^@]+$/)) {
var trimmed = query.term.trim();
emailUser = { emailUser = {
name: "Invite \"" + query.term + "\"", name: "Invite \"" + query.term + "\"",
username: query.term, username: trimmed,
id: query.term id: trimmed
}; };
data.results.unshift(emailUser); data.results.unshift(emailUser);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment