Skip to content

Commit e95ed37

Browse files
committed
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.
1 parent 0857fc9 commit e95ed37

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

linodecli/plugins/obj.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
from math import ceil
1616
from linodecli.configuration import input_helper
1717

18+
try:
19+
from urllib.parse import quote_plus
20+
except ImportError:
21+
# python2
22+
from urllib import quote_plus
23+
1824

1925
ENV_ACCESS_KEY_NAME = "LINODE_CLI_OBJ_ACCESS_KEY"
2026
ENV_SECRET_KEY_NAME = "LINODE_CLI_OBJ_SECRET_KEY"
@@ -229,7 +235,7 @@ def upload_object(get_client, args):
229235

230236
for filename, file_path in to_upload:
231237
k = Key(bucket)
232-
k.key = filename
238+
k.key = quote_plus(filename)
233239

234240
print(filename)
235241
k.set_contents_from_filename(file_path, cb=_progress, num_cb=100, policy=policy)

0 commit comments

Comments
 (0)