mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
canonicalize ETag correctly (#7442)
Fixes #7441 Trim extra quotes prefixing/suffixing ETag in CompleteMultipartUpload request.
This commit is contained in:
@@ -19,7 +19,7 @@ package cmd
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strings"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio/cmd/crypto"
|
||||
@@ -27,6 +27,10 @@ import (
|
||||
"github.com/minio/minio/pkg/handlers"
|
||||
)
|
||||
|
||||
var (
|
||||
etagRegex = regexp.MustCompile("\"*?([^\"]*?)\"*?$")
|
||||
)
|
||||
|
||||
// Validates the preconditions for CopyObjectPart, returns true if CopyObjectPart
|
||||
// operation should not proceed. Preconditions supported are:
|
||||
// x-amz-copy-source-if-modified-since
|
||||
@@ -230,8 +234,7 @@ func ifModifiedSince(objTime time.Time, givenTime time.Time) bool {
|
||||
// canonicalizeETag returns ETag with leading and trailing double-quotes removed,
|
||||
// if any present
|
||||
func canonicalizeETag(etag string) string {
|
||||
canonicalETag := strings.TrimPrefix(etag, "\"")
|
||||
return strings.TrimSuffix(canonicalETag, "\"")
|
||||
return etagRegex.ReplaceAllString(etag, "$1")
|
||||
}
|
||||
|
||||
// isETagEqual return true if the canonical representations of two ETag strings
|
||||
|
||||
Reference in New Issue
Block a user