S3 DeleteObjects - Allow multiple querystring formats

This commit is contained in:
Bert Blommers 2020-05-01 13:50:11 +01:00
parent c39924501b
commit 49b00942c3
2 changed files with 8 additions and 3 deletions

View File

@ -137,8 +137,13 @@ def parse_key_name(pth):
def is_delete_keys(request, path, bucket_name):
return path == "/?delete" or (
path == "/" and getattr(request, "query_string", "") == "delete"
# GOlang sends a request as url/?delete= (treating it as a normal key=value, even if the value is empty)
# Python sends a request as url/?delete (treating it as a flag)
# https://github.com/spulec/moto/issues/2937
return (
path == "/?delete"
or path == "/?delete="
or (path == "/" and getattr(request, "query_string", "") == "delete")
)

View File

@ -3765,7 +3765,7 @@ def test_paths_with_leading_slashes_work():
@mock_s3
def test_root_dir_with_empty_name_works():
if os.environ.get("TEST_SERVER_MODE", "false").lower() == "true":
if settings.TEST_SERVER_MODE:
raise SkipTest("Does not work in server mode due to error in Workzeug")
store_and_read_back_a_key("/")