mirror of
https://github.com/versity/versitygw.git
synced 2026-08-17 04:36:19 +00:00
Merge pull request #2170 from SebTardif/fix/parse-copy-source-empty-panic
fix: prevent panic in ParseCopySource on empty input
This commit is contained in:
@@ -230,6 +230,10 @@ func ParseCopySourceRange(size int64, acceptRange string) (int64, int64, error)
|
||||
// ParseCopySource parses x-amz-copy-source header and returns source bucket,
|
||||
// source object, versionId, error respectively
|
||||
func ParseCopySource(copySourceHeader string) (string, string, string, error) {
|
||||
if copySourceHeader == "" {
|
||||
return "", "", "", s3err.GetInvalidArgumentErr(s3err.InvalidArgCopySourceBucket, copySourceHeader)
|
||||
}
|
||||
|
||||
if copySourceHeader[0] == '/' {
|
||||
copySourceHeader = copySourceHeader[1:]
|
||||
}
|
||||
|
||||
@@ -223,6 +223,15 @@ func TestParseCopySource(t *testing.T) {
|
||||
wantErr: true,
|
||||
wantErrValue: s3err.GetInvalidArgumentErr(s3err.InvalidArgCopySourceEncoding, "mybucket/object%ZZ"),
|
||||
},
|
||||
{
|
||||
name: "empty string",
|
||||
copySourceHeader: "",
|
||||
wantBucket: "",
|
||||
wantObject: "",
|
||||
wantVersionId: "",
|
||||
wantErr: true,
|
||||
wantErrValue: s3err.GetInvalidArgumentErr(s3err.InvalidArgCopySourceBucket, ""),
|
||||
},
|
||||
{
|
||||
name: "missing object",
|
||||
copySourceHeader: "mybucket",
|
||||
|
||||
Reference in New Issue
Block a user