From e95ed37207b4e6f2ed698551f89eb16ffb3f2a2a Mon Sep 17 00:00:00 2001 From: Will Smith Date: Tue, 14 Dec 2021 15:52:54 -0500 Subject: [PATCH] bug: Fix SignatureDoesNotMatch when putting files with special characters Related to #277 @mechpaul discovered that putting filenames with some special characters, such as `\` and `$` using the `obj` plugin returns a SignatureDoesNotMatch error. To reproduce: ```bash $ echo "test" > 'test$file\name' $ python3 -m linodecli obj put 'test$file\name' some-bucket ``` This change properly quotes the URLs such that these characters are accepted in keys. --- linodecli/plugins/obj.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/linodecli/plugins/obj.py b/linodecli/plugins/obj.py index 921c93c9c..1fe703b39 100644 --- a/linodecli/plugins/obj.py +++ b/linodecli/plugins/obj.py @@ -15,6 +15,12 @@ from math import ceil from linodecli.configuration import input_helper +try: + from urllib.parse import quote_plus +except ImportError: + # python2 + from urllib import quote_plus + ENV_ACCESS_KEY_NAME = "LINODE_CLI_OBJ_ACCESS_KEY" ENV_SECRET_KEY_NAME = "LINODE_CLI_OBJ_SECRET_KEY" @@ -229,7 +235,7 @@ def upload_object(get_client, args): for filename, file_path in to_upload: k = Key(bucket) - k.key = filename + k.key = quote_plus(filename) print(filename) k.set_contents_from_filename(file_path, cb=_progress, num_cb=100, policy=policy)