Merge pull request #1430 from OwnZones/urldecode_fix

Url decode x-amz-copy-source for S3 copyObject requests
This commit is contained in:
Steve Pulec 2018-03-06 22:26:15 -05:00 committed by GitHub
commit ece7507eec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -7,6 +7,7 @@ Moto Changelog
* Supports filtering AMIs by self
* Implemented signal_workflow_execution for SWF
* Wired SWF backend to the moto server
* Added url decoding to x-amz-copy-source header for copying S3 files
* Revamped lambda function storage to do versioning
* IOT improvements
* RDS improvements

View File

@ -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
@ -647,7 +647,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]
@ -689,7 +689,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]