From 44dff36ff71d55c75f79f291ac21f2b4cda4ed3c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 13 Jan 2021 09:44:11 -0800 Subject: [PATCH] listing with prefix prefixed with '/' should be ignored (#11268) fixes #11265 --- cmd/{erasure-server-sets.go => erasure-server-pool.go} | 0 cmd/metacache-server-pool.go | 4 ++-- cmd/object-api-listobjects_test.go | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) rename cmd/{erasure-server-sets.go => erasure-server-pool.go} (100%) diff --git a/cmd/erasure-server-sets.go b/cmd/erasure-server-pool.go similarity index 100% rename from cmd/erasure-server-sets.go rename to cmd/erasure-server-pool.go diff --git a/cmd/metacache-server-pool.go b/cmd/metacache-server-pool.go index b9751cf5e..4193176fd 100644 --- a/cmd/metacache-server-pool.go +++ b/cmd/metacache-server-pool.go @@ -21,6 +21,7 @@ import ( "errors" "io" "path" + "strings" "sync" "time" @@ -53,11 +54,10 @@ func (z *erasureServerPools) listPath(ctx context.Context, o listPathOptions) (e } // For delimiter and prefix as '/' we do not list anything at all - // since according to s3 spec we stop at the 'delimiter' // along // with the prefix. On a flat namespace with 'prefix' // as '/' we don't have any entries, since all the keys are // of form 'keyName/...' - if o.Separator == SlashSeparator && o.Prefix == SlashSeparator { + if strings.HasPrefix(o.Prefix, SlashSeparator) { return entries, io.EOF } diff --git a/cmd/object-api-listobjects_test.go b/cmd/object-api-listobjects_test.go index c17060f68..dca97eebd 100644 --- a/cmd/object-api-listobjects_test.go +++ b/cmd/object-api-listobjects_test.go @@ -531,6 +531,7 @@ func testListObjects(obj ObjectLayer, instanceType string, t1 TestErrHandler) { {"test-bucket-list-object", "new", "", "", 4, resultCases[5], nil, true}, {"test-bucket-list-object", "new", "", "", 5, resultCases[5], nil, true}, {"test-bucket-list-object", "obj", "", "", 3, resultCases[6], nil, true}, + {"test-bucket-list-object", "/obj", "", "", 0, ListObjectsInfo{}, nil, true}, // Testing with prefix and truncation (29-30). {"test-bucket-list-object", "new", "", "", 1, resultCases[7], nil, true}, {"test-bucket-list-object", "obj", "", "", 2, resultCases[8], nil, true},