From b1c1f42bccccef5fc407c3bec7d25a60f91af035 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 28 Aug 2015 14:35:06 -0700 Subject: [PATCH] Fix sanitize URL bug on layer upload Update the distribution version to include sanitize URL fix Fixes #15875 Signed-off-by: Derek McGowan (github: dmcgowan) --- Dockerfile | 2 +- hack/vendor.sh | 2 +- .../registry/client/repository.go | 21 +++++++------------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0e58df1065..425b823deb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -128,7 +128,7 @@ RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint RUN gem install --no-rdoc --no-ri fpm --version 1.3.2 # Install registry -ENV REGISTRY_COMMIT 2317f721a3d8428215a2b65da4ae85212ed473b4 +ENV REGISTRY_COMMIT ec87e9b6971d831f0eff752ddb54fb64693e51cd RUN set -x \ && export GOPATH="$(mktemp -d)" \ && git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \ diff --git a/hack/vendor.sh b/hack/vendor.sh index 928e3b725f..c035b1b7a3 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -35,7 +35,7 @@ clone git github.com/coreos/go-etcd v2.0.0 clone git github.com/hashicorp/consul v0.5.2 # get graph and distribution packages -clone git github.com/docker/distribution 7dc8d4a26b689bd4892f2f2322dbce0b7119d686 +clone git github.com/docker/distribution ec87e9b6971d831f0eff752ddb54fb64693e51cd # docker/1.8 branch clone git github.com/vbatts/tar-split v0.9.6 clone git github.com/docker/notary 8e8122eb5528f621afcd4e2854c47302f17392f7 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 d0079f092a..9170af86a1 100644 --- a/vendor/src/github.com/docker/distribution/registry/client/repository.go +++ b/vendor/src/github.com/docker/distribution/registry/client/repository.go @@ -359,25 +359,18 @@ type blobs struct { distribution.BlobDeleter } -func sanitizeLocation(location, source string) (string, error) { +func sanitizeLocation(location, base string) (string, error) { + baseURL, err := url.Parse(base) + if err != nil { + return "", err + } + locationURL, err := url.Parse(location) if err != nil { return "", err } - if locationURL.Scheme == "" { - sourceURL, err := url.Parse(source) - if err != nil { - return "", err - } - locationURL = &url.URL{ - Scheme: sourceURL.Scheme, - Host: sourceURL.Host, - Path: location, - } - location = locationURL.String() - } - return location, nil + return baseURL.ResolveReference(locationURL).String(), nil } func (bs *blobs) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {