From 76042f67282730498951f21e4c8513a2a15df485 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Mon, 17 Jan 2022 15:25:29 +0300 Subject: [PATCH] [#306] Handle empty post policy Signed-off-by: Denis Kirillov --- api/handler/put.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/handler/put.go b/api/handler/put.go index 38574d2f..d753b719 100644 --- a/api/handler/put.go +++ b/api/handler/put.go @@ -368,7 +368,7 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) { } func checkPostPolicy(r *http.Request, reqInfo *api.ReqInfo, metadata map[string]string) (*postPolicy, error) { - policy := &postPolicy{} + policy := &postPolicy{empty: true} if policyStr := auth.MultipartFormValue(r, "policy"); policyStr != "" { policyData, err := base64.StdEncoding.DecodeString(policyStr) if err != nil { @@ -380,6 +380,7 @@ func checkPostPolicy(r *http.Request, reqInfo *api.ReqInfo, metadata map[string] if policy.Expiration.Before(time.Now()) { return nil, fmt.Errorf("policy is expired: %w", errors.GetAPIError(errors.ErrInvalidArgument)) } + policy.empty = false } for key, v := range r.MultipartForm.Value {