From 690341766bb3093aa64e194f9410f803af2ce5bb Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Fri, 23 Aug 2019 21:58:27 +0800 Subject: [PATCH] fix: bucket mkdir may create path with empty whitespaces --- pkg/compute/models/buckets.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/compute/models/buckets.go b/pkg/compute/models/buckets.go index 94f8d8c92e..2628e86151 100644 --- a/pkg/compute/models/buckets.go +++ b/pkg/compute/models/buckets.go @@ -630,10 +630,7 @@ func (bucket *SBucket) PerformMakedir( data jsonutils.JSONObject, ) (jsonutils.JSONObject, error) { key, _ := data.GetString("key") - for len(key) > 0 && key[len(key)-1] == '/' { - key = key[:len(key)-1] - } - + key = strings.Trim(key, " /") if len(key) == 0 { return nil, httperrors.NewInputParameterError("empty directory name") }