Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adds quotes for object Etags #1095

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ Pager:
break Pager
}
objects = append(objects, s3response.Object{
ETag: (*string)(v.Properties.ETag),
ETag: backend.GetPtrFromString(fmt.Sprintf("%q", *v.Properties.ETag)),
Key: v.Name,
LastModified: v.Properties.LastModified,
Size: v.Properties.ContentLength,
Expand Down Expand Up @@ -645,7 +645,7 @@ Pager:
break Pager
}
objects = append(objects, s3response.Object{
ETag: (*string)(v.Properties.ETag),
ETag: backend.GetPtrFromString(fmt.Sprintf("%q", *v.Properties.ETag)),
Key: v.Name,
LastModified: v.Properties.LastModified,
Size: v.Properties.ContentLength,
Expand Down
4 changes: 2 additions & 2 deletions backend/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func GetMultipartMD5(parts []types.CompletedPart) string {
for _, part := range parts {
partsEtagBytes = append(partsEtagBytes, getEtagBytes(*part.ETag)...)
}
s3MD5 := fmt.Sprintf("%s-%d", md5String(partsEtagBytes), len(parts))
return s3MD5

return fmt.Sprintf("\"%s-%d\"", md5String(partsEtagBytes), len(parts))
}

func getEtagBytes(etag string) []byte {
Expand Down
2 changes: 1 addition & 1 deletion backend/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2814,7 +2814,7 @@ func (p *Posix) PutObject(ctx context.Context, po *s3.PutObjectInput) (s3respons
}

dataSum := hash.Sum(nil)
etag := hex.EncodeToString(dataSum[:])
etag := fmt.Sprintf("\"%v\"", hex.EncodeToString(dataSum[:]))

// if the versioning is enabled, generate a new versionID for the object
var versionID string
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,9 @@ func putObjects(client *s3.Client, objs []string, bucket string) ([]types.Object
return nil, err
}
k := key
etag := strings.Trim(*res.ETag, `"`)
contents = append(contents, types.Object{
Key: &k,
ETag: &etag,
ETag: res.ETag,
StorageClass: types.ObjectStorageClassStandard,
Size: &size,
})
Expand Down
Loading