summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Lehmann <aaron.lehmann@docker.com>2016-02-08 11:07:57 -0800
committerAaron Lehmann <aaron.lehmann@docker.com>2016-02-10 14:03:41 -0800
commite2afab9c4a8be800dffee9b60b2197350987543c (patch)
tree5c47721b01e9b1088a94d011c8baef676bb550be
parentfa860c86ff0a368e686535c2689d1099fa9ea7a2 (diff)
downloaddocker-e2afab9c4a8be800dffee9b60b2197350987543c.tar.gz
Allow uppercase characters in image reference hostname
This PR makes restores the pre-Docker 1.10 behavior of allowing uppercase characters in registry hostnames. Note that this only applies to hostnames, not remote image names. Previous versions also prohibited uppercase letters after the hostname, but Docker 1.10 extended this to the hostname itself. - Vendor updated docker/distribution. - Add a check to "normalize" that rejects remote names with uppercase letters. - Add test cases to TestTagValidPrefixedRepo and TestTagInvalidUnprefixedRepo Fixes: #20056 Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
-rwxr-xr-xhack/vendor.sh2
-rw-r--r--integration-cli/docker_cli_tag_test.go4
-rw-r--r--reference/reference.go17
-rw-r--r--vendor/src/github.com/docker/distribution/reference/reference.go2
-rw-r--r--vendor/src/github.com/docker/distribution/reference/regexp.go2
-rw-r--r--vendor/src/github.com/docker/distribution/registry/client/repository.go17
6 files changed, 32 insertions, 12 deletions
diff --git a/hack/vendor.sh b/hack/vendor.sh
index a0ea6c2996..4e93dbeff9 100755
--- a/hack/vendor.sh
+++ b/hack/vendor.sh
@@ -48,7 +48,7 @@ clone git github.com/boltdb/bolt v1.1.0
clone git github.com/miekg/dns 75e6e86cc601825c5dbcd4e0c209eab180997cd7
# get graph and distribution packages
-clone git github.com/docker/distribution ab9b433fcaf7c8319562a8b80f2720f5faca712f
+clone git github.com/docker/distribution 77534e734063a203981df7024fe8ca9228b86930
clone git github.com/vbatts/tar-split v0.9.11
# get desired notary commit, might also need to be updated in Dockerfile
diff --git a/integration-cli/docker_cli_tag_test.go b/integration-cli/docker_cli_tag_test.go
index 9bacb46d6b..1e601527e6 100644
--- a/integration-cli/docker_cli_tag_test.go
+++ b/integration-cli/docker_cli_tag_test.go
@@ -31,7 +31,7 @@ func (s *DockerSuite) TestTagUnprefixedRepoByID(c *check.C) {
// ensure we don't allow the use of invalid repository names; these tag operations should fail
func (s *DockerSuite) TestTagInvalidUnprefixedRepo(c *check.C) {
- invalidRepos := []string{"fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo%asd"}
+ invalidRepos := []string{"fo$z$", "Foo@3cc", "Foo$3", "Foo*3", "Fo^3", "Foo!3", "F)xcz(", "fo%asd", "FOO/bar"}
for _, repo := range invalidRepos {
out, _, err := dockerCmdWithError("tag", "busybox", repo)
@@ -61,7 +61,7 @@ func (s *DockerSuite) TestTagValidPrefixedRepo(c *check.C) {
}
}
- validRepos := []string{"fooo/bar", "fooaa/test", "foooo:t"}
+ validRepos := []string{"fooo/bar", "fooaa/test", "foooo:t", "HOSTNAME.DOMAIN.COM:443/foo/bar"}
for _, repo := range validRepos {
_, _, err := dockerCmdWithError("tag", "busybox:latest", repo)
diff --git a/reference/reference.go b/reference/reference.go
index 1e3482475f..e355596eab 100644
--- a/reference/reference.go
+++ b/reference/reference.go
@@ -1,6 +1,7 @@
package reference
import (
+ "errors"
"fmt"
"strings"
@@ -72,7 +73,10 @@ func ParseNamed(s string) (Named, error) {
// WithName returns a named object representing the given string. If the input
// is invalid ErrReferenceInvalidFormat will be returned.
func WithName(name string) (Named, error) {
- name = normalize(name)
+ name, err := normalize(name)
+ if err != nil {
+ return nil, err
+ }
if err := validateName(name); err != nil {
return nil, err
}
@@ -172,15 +176,18 @@ func splitHostname(name string) (hostname, remoteName string) {
// normalize returns a repository name in its normalized form, meaning it
// will not contain default hostname nor library/ prefix for official images.
-func normalize(name string) string {
+func normalize(name string) (string, error) {
host, remoteName := splitHostname(name)
+ if strings.ToLower(remoteName) != remoteName {
+ return "", errors.New("invalid reference format: repository name must be lowercase")
+ }
if host == DefaultHostname {
if strings.HasPrefix(remoteName, DefaultRepoPrefix) {
- return strings.TrimPrefix(remoteName, DefaultRepoPrefix)
+ return strings.TrimPrefix(remoteName, DefaultRepoPrefix), nil
}
- return remoteName
+ return remoteName, nil
}
- return name
+ return name, nil
}
func validateName(name string) error {
diff --git a/vendor/src/github.com/docker/distribution/reference/reference.go b/vendor/src/github.com/docker/distribution/reference/reference.go
index c188472a40..6f079cbb1a 100644
--- a/vendor/src/github.com/docker/distribution/reference/reference.go
+++ b/vendor/src/github.com/docker/distribution/reference/reference.go
@@ -6,7 +6,7 @@
// reference := repository [ ":" tag ] [ "@" digest ]
// name := [hostname '/'] component ['/' component]*
// hostname := hostcomponent ['.' hostcomponent]* [':' port-number]
-// hostcomponent := /([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])/
+// hostcomponent := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/
// port-number := /[0-9]+/
// component := alpha-numeric [separator alpha-numeric]*
// alpha-numeric := /[a-z0-9]+/
diff --git a/vendor/src/github.com/docker/distribution/reference/regexp.go b/vendor/src/github.com/docker/distribution/reference/regexp.go
index a4ffe5b642..b465abf5d0 100644
--- a/vendor/src/github.com/docker/distribution/reference/regexp.go
+++ b/vendor/src/github.com/docker/distribution/reference/regexp.go
@@ -22,7 +22,7 @@ var (
// hostnameComponentRegexp restricts the registry hostname component of a
// repository name to start with a component as defined by hostnameRegexp
// and followed by an optional port.
- hostnameComponentRegexp = match(`(?:[a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])`)
+ hostnameComponentRegexp = match(`(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])`)
// hostnameRegexp defines the structure of potential hostname components
// that may be part of image names. This is purposely a subset of what is
diff --git a/vendor/src/github.com/docker/distribution/registry/client/repository.go b/vendor/src/github.com/docker/distribution/registry/client/repository.go
index 1e8c4fa98e..ebf44d4733 100644
--- a/vendor/src/github.com/docker/distribution/registry/client/repository.go
+++ b/vendor/src/github.com/docker/distribution/registry/client/repository.go
@@ -36,8 +36,21 @@ func checkHTTPRedirect(req *http.Request, via []*http.Request) error {
if len(via) > 0 {
for headerName, headerVals := range via[0].Header {
- if headerName == "Accept" || headerName == "Range" {
- for _, val := range headerVals {
+ if headerName != "Accept" && headerName != "Range" {
+ continue
+ }
+ for _, val := range headerVals {
+ // Don't add to redirected request if redirected
+ // request already has a header with the same
+ // name and value.
+ hasValue := false
+ for _, existingVal := range req.Header[headerName] {
+ if existingVal == val {
+ hasValue = true
+ break
+ }
+ }
+ if !hasValue {
req.Header.Add(headerName, val)
}
}