Browse code

Fix sanitize URL bug on layer upload

Update the distribution version to include sanitize URL fix

Fixes #15875

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)

Derek McGowan authored on 2015/08/29 06:35:06
Showing 3 changed files
... ...
@@ -128,7 +128,7 @@ RUN git clone https://github.com/golang/lint.git /go/src/github.com/golang/lint
128 128
 RUN gem install --no-rdoc --no-ri fpm --version 1.3.2
129 129
 
130 130
 # Install registry
131
-ENV REGISTRY_COMMIT 2317f721a3d8428215a2b65da4ae85212ed473b4
131
+ENV REGISTRY_COMMIT ec87e9b6971d831f0eff752ddb54fb64693e51cd
132 132
 RUN set -x \
133 133
 	&& export GOPATH="$(mktemp -d)" \
134 134
 	&& git clone https://github.com/docker/distribution.git "$GOPATH/src/github.com/docker/distribution" \
... ...
@@ -35,7 +35,7 @@ clone git github.com/coreos/go-etcd v2.0.0
35 35
 clone git github.com/hashicorp/consul v0.5.2
36 36
 
37 37
 # get graph and distribution packages
38
-clone git github.com/docker/distribution 7dc8d4a26b689bd4892f2f2322dbce0b7119d686
38
+clone git github.com/docker/distribution ec87e9b6971d831f0eff752ddb54fb64693e51cd # docker/1.8 branch
39 39
 clone git github.com/vbatts/tar-split v0.9.6
40 40
 
41 41
 clone git github.com/docker/notary 8e8122eb5528f621afcd4e2854c47302f17392f7
... ...
@@ -359,25 +359,18 @@ type blobs struct {
359 359
 	distribution.BlobDeleter
360 360
 }
361 361
 
362
-func sanitizeLocation(location, source string) (string, error) {
363
-	locationURL, err := url.Parse(location)
362
+func sanitizeLocation(location, base string) (string, error) {
363
+	baseURL, err := url.Parse(base)
364 364
 	if err != nil {
365 365
 		return "", err
366 366
 	}
367 367
 
368
-	if locationURL.Scheme == "" {
369
-		sourceURL, err := url.Parse(source)
370
-		if err != nil {
371
-			return "", err
372
-		}
373
-		locationURL = &url.URL{
374
-			Scheme: sourceURL.Scheme,
375
-			Host:   sourceURL.Host,
376
-			Path:   location,
377
-		}
378
-		location = locationURL.String()
368
+	locationURL, err := url.Parse(location)
369
+	if err != nil {
370
+		return "", err
379 371
 	}
380
-	return location, nil
372
+
373
+	return baseURL.ResolveReference(locationURL).String(), nil
381 374
 }
382 375
 
383 376
 func (bs *blobs) Stat(ctx context.Context, dgst digest.Digest) (distribution.Descriptor, error) {