Allow more email RFC accepted chars in username
Issue:
Gerrit allows to specify email like username (especially handy
when one wants to maintain unique email addresses across the server).
However as opposite to what is described in [1] it allows only:
._- characters from allowed set that contains !#$%&‘*+–/=?^_`.{|}~
Considering the fact that I was able to perform clone (over SSH
and HTTP) push for review, review and submit with all those
characters but / this patch proposes to extend username allowed
chars to !#$%&‘*+–=?^_`.{|}~ when @ is used (we have email like
username) but keeps original characters set a-zA-Z0-9 when one
uses single character for username.
[1] https://www.mailboxvalidator.com/resources/articles/acceptable-email-address-syntax-rfc/
Change-Id: Iabb82cea5be32a68fe1d9fc65a6ca08743063a3f
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
This commit is contained in:
@@ -856,7 +856,13 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
public void createUserWithValidUsername() throws Exception {
|
||||
ImmutableList<String> names =
|
||||
ImmutableList.of(
|
||||
"user@domain", "user-name", "user_name", "1234", "user1234", "1234@domain");
|
||||
"user@domain",
|
||||
"user-name",
|
||||
"user_name",
|
||||
"1234",
|
||||
"user1234",
|
||||
"1234@domain",
|
||||
"user!+alias{*}#$%&’^=~|@domain");
|
||||
for (String name : names) {
|
||||
gApi.accounts().create(name);
|
||||
}
|
||||
@@ -864,7 +870,10 @@ public class AccountIT extends AbstractDaemonTest {
|
||||
|
||||
@Test
|
||||
public void createUserWithInvalidUsername() throws Exception {
|
||||
ImmutableList<String> invalidNames = ImmutableList.of("@", "@foo", "-", "-foo", "_", "_foo");
|
||||
ImmutableList<String> invalidNames =
|
||||
ImmutableList.of(
|
||||
"@", "@foo", "-", "-foo", "_", "_foo", "!", "+", "{", "}", "*", "%", "#", "$", "&", "’",
|
||||
"^", "=", "~");
|
||||
for (String name : invalidNames) {
|
||||
try {
|
||||
gApi.accounts().create(name);
|
||||
|
||||
@@ -41,7 +41,7 @@ class UsernameField extends Composite {
|
||||
// corresponding regular expressions in the
|
||||
// com.google.gerrit.server.account.ExternalId class.
|
||||
private static final String USER_NAME_PATTERN_FIRST_REGEX = "[a-zA-Z0-9]";
|
||||
private static final String USER_NAME_PATTERN_REST_REGEX = "[a-zA-Z0-9._@-]";
|
||||
private static final String USER_NAME_PATTERN_REST_REGEX = "[a-zA-Z0-9.!#$%&’*+=?^_`\\{|\\}~@-]";
|
||||
|
||||
private CopyableLabel userNameLbl;
|
||||
private NpTextBox userNameTxt;
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class ExternalId implements Serializable {
|
||||
// corresponding regular expressions in the
|
||||
// com.google.gerrit.client.account.UsernameField class.
|
||||
private static final String USER_NAME_PATTERN_FIRST_REGEX = "[a-zA-Z0-9]";
|
||||
private static final String USER_NAME_PATTERN_REST_REGEX = "[a-zA-Z0-9._@-]";
|
||||
private static final String USER_NAME_PATTERN_REST_REGEX = "[a-zA-Z0-9.!#$%&’*+=?^_`\\{|\\}~@-]";
|
||||
private static final String USER_NAME_PATTERN_LAST_REGEX = "[a-zA-Z0-9]";
|
||||
|
||||
/** Regular expression that a username must match. */
|
||||
|
||||
Reference in New Issue
Block a user