Skip to content

Commit

Permalink
s3cmd: handle cases of empty key or value for settagging
Browse files Browse the repository at this point in the history
  • Loading branch information
fviard committed Dec 12, 2023
1 parent 4d97114 commit 042b7e1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions s3cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2481,10 +2481,15 @@ def cmd_settagging(args):
uri = S3Uri(args[0])
tag_set_string = args[1]

tagsets = [
tuple(tagset.split("="))
for tagset in tag_set_string.split("&")
]
tagsets = []
for tagset in tag_set_string.split("&"):
keyval = tagset.split("=", 1)
key = keyval[0]
if not key:
raise ParameterError("Tag key should not be empty")
value = len(keyval) > 1 and keyval[1] or ""
tagsets.append((key, value))

debug(tagsets)
response = s3.set_tagging(uri, tagsets)

Expand Down

0 comments on commit 042b7e1

Please sign in to comment.