From 50a8ba6a6f243f5b611b8a5d2df069d21c530646 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 23 Sep 2022 08:49:27 -0700 Subject: [PATCH] fix: parse and save retainUntilDate in correct time format (#15741) --- cmd/bucket-replication.go | 7 +++++-- cmd/object-handlers.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/bucket-replication.go b/cmd/bucket-replication.go index e4bf92414..69519659a 100644 --- a/cmd/bucket-replication.go +++ b/cmd/bucket-replication.go @@ -730,9 +730,12 @@ func putReplicationOpts(ctx context.Context, sc string, objInfo ObjectInfo) (put putOpts.Mode = rmode } if retainDateStr, ok := lkMap.Lookup(xhttp.AmzObjectLockRetainUntilDate); ok { - rdate, err := time.Parse(time.RFC3339, retainDateStr) + rdate, err := time.Parse(iso8601TimeFormat, retainDateStr) if err != nil { - return putOpts, err + rdate, err = time.Parse(time.RFC3339, retainDateStr) + if err != nil { + return putOpts, err + } } putOpts.RetainUntilDate = rdate // set retention timestamp in opts diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 2dfb7b9f3..1c9993c36 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -2998,7 +2998,7 @@ func (api objectAPIHandlers) PutObjectRetentionHandler(w http.ResponseWriter, r } if objRetention.Mode.Valid() { oi.UserDefined[strings.ToLower(xhttp.AmzObjectLockMode)] = string(objRetention.Mode) - oi.UserDefined[strings.ToLower(xhttp.AmzObjectLockRetainUntilDate)] = objRetention.RetainUntilDate.UTC().Format(time.RFC3339) + oi.UserDefined[strings.ToLower(xhttp.AmzObjectLockRetainUntilDate)] = objRetention.RetainUntilDate.UTC().Format(iso8601TimeFormat) } else { oi.UserDefined[strings.ToLower(xhttp.AmzObjectLockMode)] = "" oi.UserDefined[strings.ToLower(xhttp.AmzObjectLockRetainUntilDate)] = ""