Fix copying S3 objects with question marks in keys
PR #2062 fixes copy for unicode keys. However, the change breaks keys with question marks. Here is an alternative fix that works for both emojis and question marks. I notice this when running the test suite of aiobotocore. One of the tests [1] is broken with moto >= 1.3.8. [1] https://github.com/aio-libs/aiobotocore/blob/0.10.3/tests/test_basic_s3.py#L314-L329
This commit is contained in:
parent
4497f18c1a
commit
6c0a2dc374
2 changed files with 10 additions and 6 deletions
|
|
@ -913,11 +913,11 @@ class ResponseObject(_TemplateEnvironmentMixin, ActionAuthenticatorMixin):
|
|||
# Copy key
|
||||
# you can have a quoted ?version=abc with a version Id, so work on
|
||||
# we need to parse the unquoted string first
|
||||
src_key = clean_key_name(request.headers.get("x-amz-copy-source"))
|
||||
src_key = request.headers.get("x-amz-copy-source")
|
||||
if isinstance(src_key, six.binary_type):
|
||||
src_key = src_key.decode('utf-8')
|
||||
src_key_parsed = urlparse(src_key)
|
||||
src_bucket, src_key = unquote(src_key_parsed.path).\
|
||||
src_bucket, src_key = clean_key_name(src_key_parsed.path).\
|
||||
lstrip("/").split("/", 1)
|
||||
src_version_id = parse_qs(src_key_parsed.query).get(
|
||||
'versionId', [None])[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue