allow additional characters in usernames and passwords (#1580) (#1666)

This commit is contained in:
Alessandro Ros 2023-04-09 14:06:25 +02:00 committed by GitHub
parent d72dab858e
commit e426810455
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -7,9 +7,9 @@ import (
"strings"
)
var reCredential = regexp.MustCompile(`^[a-zA-Z0-9!\$\(\)\*\+\.;<=>\[\]\^_\-\{\}]+$`)
var reCredential = regexp.MustCompile(`^[a-zA-Z0-9!\$\(\)\*\+\.;<=>\[\]\^_\-\{\}@#&]+$`)
const credentialSupportedChars = "A-Z,0-9,!,$,(,),*,+,.,;,<,=,>,[,],^,_,-,{,}"
const credentialSupportedChars = "A-Z,0-9,!,$,(,),*,+,.,;,<,=,>,[,],^,_,-,\",\",@,#,&"
// Credential is a parameter that is used as username or password.
type Credential string
@ -29,7 +29,7 @@ func (d *Credential) UnmarshalJSON(b []byte) error {
if in != "" &&
!strings.HasPrefix(in, "sha256:") &&
!reCredential.MatchString(in) {
return fmt.Errorf("contains unsupported characters (supported are %s)", credentialSupportedChars)
return fmt.Errorf("credential contains unsupported characters. Supported are: %s", credentialSupportedChars)
}
*d = Credential(in)