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 CopyObject for CopySource containing a key with slashes #213

Conversation

mcayland
Copy link
Contributor

When attempting to use CopyObject with a CopySource key containing slashes such as bar/baz/mypic.jpg S3Ninja returns an error:

"sirius.kernel.health.HandledException: An error occurred: Bucket name "mybucket/bar/baz"; does not adhere to the rules.
[https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html]"

The problem is that S3Dispatcher's copyObject() doesn't correctly parse the bucket name and key from x-amz-copy-source as copy.lastIndexOf(PATH_DELIMITER) returns the index of the last separator in the key, rather than the index of first separator after the bucket name.

When attempting to use CopyObject with a CopySource key containing slashes
such as bar/baz/mypic.jpg S3Ninja returns an error:

"sirius.kernel.health.HandledException: An error occurred: Bucket name
"mybucket/bar/baz"; does not adhere to the rules.
[https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html]"

The problem is that S3Dispatcher's copyObject() doesn't correctly parse
the bucket name and key from x-amz-copy-source as
copy.lastIndexOf(PATH_DELIMITER) returns the index of the last separator
in the key, rather than the index of first separator after the bucket
name.

Signed-off-by: Mark Cave-Ayland <[email protected]>
@andyHa
Copy link
Member

andyHa commented Jan 26, 2023

https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html - The code checks out, as bucket names must not contains slashes.

@jakobvogel jakobvogel merged commit 5004aeb into scireum:develop Jan 26, 2023
@jakobvogel
Copy link
Member

Many thanks @mcayland!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants