From a4f870025f674d6e2e9b682e74b67716a5a8d45b Mon Sep 17 00:00:00 2001 From: Benjamin Simon Date: Sun, 22 Oct 2023 20:13:19 +0200 Subject: [PATCH] fix URL decoding of x-amz-copy-source --- 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 e5fbed0319ca..99f73e06774b 100644 --- a/moto/s3/responses.py +++ b/moto/s3/responses.py @@ -1482,9 +1482,9 @@ def _key_response_put( if isinstance(copy_source, bytes): copy_source = copy_source.decode("utf-8") copy_source_parsed = urlparse(copy_source) - url_path = copy_source_parsed.path - # this path should not be decoded, as it is not encoded in the headers - src_bucket, src_key = url_path.lstrip("/").split("/", 1) + src_bucket, src_key = ( + unquote(copy_source_parsed.path).lstrip("/").split("/", 1) + ) src_version_id = parse_qs(copy_source_parsed.query).get( "versionId", [None] # type: ignore )[0]