From 5cef006c5a8ac0c0b771d78999119ff2db029e10 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Sat, 7 Jun 2014 21:17:56 +0000 Subject: [PATCH] improve trusted location detection Docker-DCO-1.1-Signed-off-by: Victor Vieux (github: vieux) --- docs/registry.go | 2 +- docs/registry_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/registry.go b/docs/registry.go index 8d1a9f22..95cc7406 100644 --- a/docs/registry.go +++ b/docs/registry.go @@ -766,7 +766,7 @@ func trustedLocation(req *http.Request) bool { } for _, trusted := range trusteds { - if strings.HasSuffix(hostname, trusted) { + if hostname == trusted || strings.HasSuffix(hostname, "."+trusted) { return true } } diff --git a/docs/registry_test.go b/docs/registry_test.go index 2857ab4a..91a5ffa1 100644 --- a/docs/registry_test.go +++ b/docs/registry_test.go @@ -235,7 +235,7 @@ func TestValidRepositoryName(t *testing.T) { } func TestTrustedLocation(t *testing.T) { - for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.io"} { + for _, url := range []string{"http://example.com", "https://example.com:7777", "http://docker.io", "http://test.docker.io", "https://fakedocker.com"} { req, _ := http.NewRequest("GET", url, nil) if trustedLocation(req) == true { t.Fatalf("'%s' shouldn't be detected as a trusted location", url)