mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-05 19:47:47 +01:00
S3: quote ETag in CopyObject and UploadPartCopy XML responses (#11624)
* s3api: extract quoteETag from setEtag Consolidate ETag quoting so the XML response builders can share it. * s3api: quote ETag in CopyObjectResult XML AWS returns the ETag quoted in the copy result body, matching the ETag header. Fixes seaweedfs/seaweedfs#11622 * s3api: quote ETag in CopyPartResult XML UploadPartCopy returned the raw ETag in the XML body while the response header and other APIs return it quoted. Fixes seaweedfs/seaweedfs#11622 * s3api: test ETag quoting in copy responses * s3api: assert quoted ETag on the wire in copy response tests * s3api: use strconv.Quote in quoteETag Addresses CodeQL 'potentially unsafe quoting' on string concatenation.
This commit is contained in:
1 parent
cac6cd4b16
commit
ec261c5fbc
4 files changed
+55
-15
No files matched your search
@@ -374,7 +374,7 @@ func (s3a *S3ApiServer) CopyObjectHandler(w http.ResponseWriter, r *http.Request
|
||||
}
|
||||
setEtag(w, etag)
|
||||
writeSuccessResponseXML(w, r, CopyObjectResult{
|
||||
ETag: etag,
|
||||
ETag: quoteETag(etag),
|
||||
LastModified: t,
|
||||
})
|
||||
return
|
||||
@@ -546,7 +546,7 @@ func (s3a *S3ApiServer) CopyObjectHandler(w http.ResponseWriter, r *http.Request
|
||||
setEtag(w, etag)
|
||||
|
||||
response := CopyObjectResult{
|
||||
ETag: etag,
|
||||
ETag: quoteETag(etag),
|
||||
LastModified: t,
|
||||
}
|
||||
|
||||
@@ -863,7 +863,7 @@ func (r CopyPartResult) MarshalXML(e *xml.Encoder, start xml.StartElement) error
|
||||
|
||||
func buildCopyPartResult(etag string, lastModified time.Time, metadata SSEResponseMetadata) CopyPartResult {
|
||||
result := CopyPartResult{
|
||||
ETag: etag,
|
||||
ETag: quoteETag(etag),
|
||||
LastModified: lastModified,
|
||||
}
|
||||
result.SetChecksum(metadata.ChecksumHeaderName, metadata.ChecksumValue)
|
||||
@@ -1086,7 +1086,7 @@ func (s3a *S3ApiServer) CopyObjectPartHandler(w http.ResponseWriter, r *http.Req
|
||||
if !s3a.checkUploadStillOpen(w, r, dstBucket, dstObject, uploadID) {
|
||||
return
|
||||
}
|
||||
setEtag(w, "\""+strings.Trim(etag, "\"")+"\"")
|
||||
setEtag(w, etag)
|
||||
// Mirror PutObjectPartHandler: write x-amz-server-side-encryption /
|
||||
// x-amz-server-side-encryption-aws-kms-key-id headers on the response
|
||||
// so clients can see the destination's encryption state.
|
||||
|
||||
Reference in new issue
Block a user