From 52b159b1db8f99119ced93923592a229b64b8918 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 13 Dec 2018 22:04:37 -0800 Subject: [PATCH] Allow versionId to be null for Delete,CopyObjectPart (#6972) --- cmd/object-handlers.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cmd/object-handlers.go b/cmd/object-handlers.go index 52e0926c0..7a101a63a 100644 --- a/cmd/object-handlers.go +++ b/cmd/object-handlers.go @@ -1454,6 +1454,22 @@ func (api objectAPIHandlers) CopyObjectPartHandler(w http.ResponseWriter, r *htt cpSrcPath = r.Header.Get("X-Amz-Copy-Source") } + // Check https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html + // Regardless of whether you have enabled versioning, each object in your bucket + // has a version ID. If you have not enabled versioning, Amazon S3 sets the value + // of the version ID to null. If you have enabled versioning, Amazon S3 assigns a + // unique version ID value for the object. + if u, err := url.Parse(cpSrcPath); err == nil { + // Check if versionId query param was added, if yes then check if + // its non "null" value, we should error out since we do not support + // any versions other than "null". + if vid := u.Query().Get("versionId"); vid != "" && vid != "null" { + writeErrorResponse(w, ErrNoSuchVersion, r.URL, guessIsBrowserReq(r)) + return + } + cpSrcPath = u.Path + } + srcBucket, srcObject := path2BucketAndObject(cpSrcPath) // If source object is empty or bucket is empty, reply back invalid copy source. if srcObject == "" || srcBucket == "" { @@ -2242,6 +2258,11 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http. return } + if vid := r.URL.Query().Get("versionId"); vid != "" && vid != "null" { + writeErrorResponse(w, ErrNoSuchVersion, r.URL, guessIsBrowserReq(r)) + return + } + // Deny if WORM is enabled if globalWORMEnabled { // Not required to check whether given object exists or not, because