From ef9b229acc0da428c5fc3f8a588cb3cae2bed213 Mon Sep 17 00:00:00 2001 From: Ciprian Radulescu Date: Sun, 14 Jan 2018 18:49:47 +0200 Subject: [PATCH 1/3] url decode x-amz-copy-source as per s3 nodejs documentation --- moto/s3/responses.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/moto/s3/responses.py b/moto/s3/responses.py index 6abb4f2d..1cd505cc 100755 --- a/moto/s3/responses.py +++ b/moto/s3/responses.py @@ -4,7 +4,7 @@ import re import six from moto.core.utils import str_to_rfc_1123_datetime -from six.moves.urllib.parse import parse_qs, urlparse +from six.moves.urllib.parse import parse_qs, urlparse, unquote import xmltodict @@ -631,7 +631,7 @@ class ResponseObject(_TemplateEnvironmentMixin): upload_id = query['uploadId'][0] part_number = int(query['partNumber'][0]) if 'x-amz-copy-source' in request.headers: - src = request.headers.get("x-amz-copy-source").lstrip("/") + src = unquote(request.headers.get("x-amz-copy-source")).lstrip("/") src_bucket, src_key = src.split("/", 1) src_range = request.headers.get( 'x-amz-copy-source-range', '').split("bytes=")[-1] @@ -673,7 +673,7 @@ class ResponseObject(_TemplateEnvironmentMixin): if 'x-amz-copy-source' in request.headers: # Copy key - src_key_parsed = urlparse(request.headers.get("x-amz-copy-source")) + src_key_parsed = urlparse(unquote(request.headers.get("x-amz-copy-source"))) src_bucket, src_key = src_key_parsed.path.lstrip("/").split("/", 1) src_version_id = parse_qs(src_key_parsed.query).get( 'versionId', [None])[0] From 055bc0f5d7279d4a85c74f945d2cd8752b65fe39 Mon Sep 17 00:00:00 2001 From: Ciprian Radulescu Date: Sun, 14 Jan 2018 19:57:45 +0200 Subject: [PATCH 2/3] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b10967f6..4e463256 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Latest * Implemented signal_workflow_execution for SWF * Wired SWF backend to the moto server * Fixed incorrect handling of task list parameter on start_workflow_execution + * Added url decoding to x-amz-copy-source header for copying S3 files 1.1.25 ----- From 2beb004006666950d92b78a32bd18e1b24f796c5 Mon Sep 17 00:00:00 2001 From: Ciprian Radulescu Date: Sun, 14 Jan 2018 20:02:49 +0200 Subject: [PATCH 3/3] updated changelog for pull request --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e463256..e8c6abb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ Latest ------ * Implemented signal_workflow_execution for SWF * Wired SWF backend to the moto server - * Fixed incorrect handling of task list parameter on start_workflow_execution * Added url decoding to x-amz-copy-source header for copying S3 files 1.1.25