Allow = in user identifiers (#1590)

While I was breaking through all the TDD bureaucracy to finally push this fix,
it turned out that it already got fixed in #1578. Still I push the rest of the
changes (basically, everything except of actually fixing the bug ;)).

`=` is crucial for matrix-bifrost which turns XMPP @'s into =40.

Signed-off-by: Bohdan Horbeshko <bodqhrohro@gmail.com>
This commit is contained in:
bodqhrohro 2020-11-19 00:56:06 +02:00 committed by GitHub
parent e65a3443a4
commit 1cf9f20d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -209,7 +209,7 @@ func validateUsername(username string) *util.JSONResponse {
} else if !validUsernameRegex.MatchString(username) {
return &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./'"),
JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./='"),
}
} else if username[0] == '_' { // Regex checks its not a zero length string
return &util.JSONResponse{
@ -230,7 +230,7 @@ func validateApplicationServiceUsername(username string) *util.JSONResponse {
} else if !validUsernameRegex.MatchString(username) {
return &util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./'"),
JSON: jsonerror.InvalidUsername("Username can only contain characters a-z, 0-9, or '_-./='"),
}
}
return nil

View File

@ -16,6 +16,13 @@ POST /register rejects registration of usernames with '£'
POST /register rejects registration of usernames with 'é'
POST /register rejects registration of usernames with '\n'
POST /register rejects registration of usernames with '''
POST /register allows registration of usernames with 'q'
POST /register allows registration of usernames with '3'
POST /register allows registration of usernames with '.'
POST /register allows registration of usernames with '_'
POST /register allows registration of usernames with '='
POST /register allows registration of usernames with '-'
POST /register allows registration of usernames with '/'
GET /login yields a set of flows
POST /login can log in as a user
POST /login returns the same device_id as that in the request