Merge pull request #2979 from avtakkar/avtakkar/fix-domain-split

Fix bug in parsing domain from repository reference
This commit is contained in:
Derek McGowan 2021-03-01 09:35:14 -08:00 committed by GitHub
commit 90e62ac24c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View file

@ -89,7 +89,7 @@ func ParseDockerRef(ref string) (Named, error) {
// needs to be already validated before.
func splitDockerDomain(name string) (domain, remainder string) {
i := strings.IndexRune(name, '/')
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost") {
if i == -1 || (!strings.ContainsAny(name[:i], ".:") && name[:i] != "localhost" && strings.ToLower(name[:i]) == name[:i]) {
domain, remainder = defaultDomain, name
} else {
domain, remainder = name[:i], name[i+1:]

View file

@ -28,6 +28,8 @@ func TestValidateReferenceName(t *testing.T) {
// when specified with a hostname, it removes the ambiguity from about
// whether the value is an identifier or repository name
"docker.io/1a3f5e7d9c1b3a5f7e9d1c3b5a7f9e1d3c5b7a9f1e3d5d7c9b1a3f5e7d9c1b3a",
"Docker/docker",
"DOCKER/docker",
}
invalidRepoNames := []string{
"https://github.com/docker/docker",
@ -229,6 +231,20 @@ func TestParseRepositoryInfo(t *testing.T) {
AmbiguousName: "",
Domain: "docker.io",
},
{
RemoteName: "bar",
FamiliarName: "Foo/bar",
FullName: "Foo/bar",
AmbiguousName: "",
Domain: "Foo",
},
{
RemoteName: "bar",
FamiliarName: "FOO/bar",
FullName: "FOO/bar",
AmbiguousName: "",
Domain: "FOO",
},
}
for _, tcase := range tcases {