From 2f43709f85da19dffbba1e6b05ca4eecf40f0255 Mon Sep 17 00:00:00 2001 From: Aditya Manthramurthy Date: Wed, 16 Nov 2016 16:23:22 -0800 Subject: [PATCH] Prevent gorilla mux from normalizing path (Fixes #3256) (#3268) Also fix test to not use a bucket name with a leading slash - this causes the bucket name to become empty and go to an unintended API call (listbuckets). --- cmd/routers.go | 5 +++-- cmd/server_test.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/routers.go b/cmd/routers.go index 43c2f0c57..18d0f5dcf 100644 --- a/cmd/routers.go +++ b/cmd/routers.go @@ -77,8 +77,9 @@ func newObjectLayer(storageDisks []StorageAPI) (ObjectLayer, error) { // configureServer handler returns final handler for the http server. func configureServerHandler(srvCmdConfig serverCmdConfig) (http.Handler, error) { - // Initialize router. - mux := router.NewRouter() + // Initialize router. `SkipClean(true)` stops gorilla/mux from + // normalizing URL path minio/minio#3256 + mux := router.NewRouter().SkipClean(true) // Initialize distributed NS lock. if globalIsDistXL { diff --git a/cmd/server_test.go b/cmd/server_test.go index 461d76f0a..795ef2f94 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -1971,7 +1971,7 @@ func (s *TestSuiteCommon) TestGetObjectErrors(c *C) { verifyError(c, response, "NoSuchKey", "The specified key does not exist.", http.StatusNotFound) // request to download an object, but an invalid bucket name is set. - request, err = newTestSignedRequest("GET", getGetObjectURL(s.endPoint, "/getobjecterrors-.", objectName), + request, err = newTestSignedRequest("GET", getGetObjectURL(s.endPoint, "getobjecterrors-.", objectName), 0, nil, s.accessKey, s.secretKey, s.signer) c.Assert(err, IsNil)