From c9b4c49320a82a79fe8b00d00373432e6d0c4a2f Mon Sep 17 00:00:00 2001 From: Bala FA Date: Sun, 18 Aug 2024 03:46:17 +0530 Subject: [PATCH] SignV4: trim leading/trailing spaces in header value (#1435) Signed-off-by: Bala.FA --- minio/signer.py | 2 +- tests/functional/tests.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/minio/signer.py b/minio/signer.py index 3e60beb91..83cf89831 100644 --- a/minio/signer.py +++ b/minio/signer.py @@ -74,7 +74,7 @@ def _get_canonical_headers( ): values = values if isinstance(values, (list, tuple)) else [values] ordered_headers[key] = ",".join([ - _MULTI_SPACE_REGEX.sub(" ", value) for value in values + _MULTI_SPACE_REGEX.sub(" ", value).strip() for value in values ]) ordered_headers = OrderedDict(sorted(ordered_headers.items())) diff --git a/tests/functional/tests.py b/tests/functional/tests.py index 7def5ba85..f6a043f2d 100644 --- a/tests/functional/tests.py +++ b/tests/functional/tests.py @@ -692,7 +692,12 @@ def test_put_object(log_entry, sse=None): reader = LimitedRandomReader(length) log_entry["args"]["data"] = "LimitedRandomReader(11 * MB)" log_entry["args"]["metadata"] = metadata = { - 'x-amz-meta-testing': 'value', 'test-key': 'value2'} + 'x-amz-meta-testing': 'value', + 'test-key': 'value2', + "My-Project": "Project One", + "My-header1": " a b c ", + "My-Header2": "\"a b c\"", + } log_entry["args"]["content_type"] = content_type = ( "application/octet-stream") log_entry["args"]["object_name"] = object_name + "-metadata"