-
Notifications
You must be signed in to change notification settings - Fork 527
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
Escape the special char in name correctly. As per the AWS documentat… #579
Conversation
…on, CopyRequest is sending request param and it advised to URLEncode the source name. Using the url.QueryEscape to encode the name instead of urlPahEscape since it does not cover all special char.
Fixes #580 |
@@ -475,7 +475,7 @@ func (s *S3Backend) mpuCopyPart(from string, to string, mpuId string, bytes stri | |||
params := &s3.UploadPartCopyInput{ | |||
Bucket: &s.bucket, | |||
Key: &to, | |||
CopySource: aws.String(pathEscape(from)), | |||
CopySource: aws.String(url.QueryEscape(from)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the QueryEscape
to encode URLEncode the params.
@@ -667,7 +667,7 @@ func (s *S3Backend) CopyBlob(param *CopyBlobInput) (*CopyBlobOutput, error) { | |||
|
|||
params := &s3.CopyObjectInput{ | |||
Bucket: &s.bucket, | |||
CopySource: aws.String(pathEscape(from)), | |||
CopySource: aws.String(url.QueryEscape(from)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the QueryEscape
to encode URLEncode the params. The from
is a leaf node (just name, not a path) hence QueryEscape
will escape all special characters. Even if the from
has a forward slash (/
) then it will be escaped and AWS unescaping and working correctly.
@@ -571,13 +571,6 @@ func mapAwsError(err error) error { | |||
} | |||
} | |||
|
|||
// note that this is NOT the same as url.PathEscape in golang 1.8, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed since it is not used anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. I think we should get this merged, just need a rebase before we can do that
merged via 5ae08c0 |
Escape the special char in name correctly. As per the AWS documentation, CopyRequest is sending request param and it advised to URLEncode the source name. Using the
url.QueryEscape
to encode the name instead ofurl.PahEscape
since it does not cover all special char.