sshutil: allow uppercase usernames (thinking of you thaJeztah)

Signed-off-by: Tibor Vass <tibor@docker.com>
v0.8
Tibor Vass 2020-12-11 05:19:39 +00:00
parent 201482bba9
commit fbf8ed15a8
2 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import (
"regexp"
)
var gitSSHRegex = regexp.MustCompile("^[a-z0-9-_]+@[a-zA-Z0-9-.]+:.*$")
var gitSSHRegex = regexp.MustCompile("^[a-zA-Z0-9-_]+@[a-zA-Z0-9-.]+:.*$")
func IsSSHTransport(s string) bool {
return gitSSHRegex.MatchString(s)

View File

@ -17,7 +17,7 @@ func TestIsSSHTransport(t *testing.T) {
require.False(t, IsSSHTransport(""))
require.True(t, IsSSHTransport("git@github.com:moby/buildkit.git"))
require.True(t, IsSSHTransport("nonstandarduser@example.com:/srv/repos/weird/project.git"))
require.True(t, IsSSHTransport("other_funky-username52@example.com:path/to/repo.git/"))
require.True(t, IsSSHTransport("other_funky-username52@example.com:/to/really:odd:repo.git/"))
require.True(t, IsSSHTransport("other_Funky-username52@example.com:path/to/repo.git/"))
require.True(t, IsSSHTransport("other_Funky-username52@example.com:/to/really:odd:repo.git/"))
require.True(t, IsSSHTransport("teddy@4houses-down.com:/~/catnip.git/"))
}