Skip to content

Commit 7980622

Browse files
fix: don't unnecessarily strip valid characters from secret data
1 parent d61ea7d commit 7980622

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

juju/secrets.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,10 @@ def create_secret_data(args):
2727
"""
2828
data = {}
2929
for val in args:
30-
# Remove any base64 padding ("=") before splitting the key=value.
31-
stripped = val.rstrip(base64.b64encode(b"=").decode("utf-8"))
32-
idx = stripped.find("=")
33-
if idx < 1:
30+
key, _, value = val.partition('=')
31+
if not key or not value:
3432
raise ValueError(f"Invalid key value {val}")
3533

36-
key = stripped[0:idx]
37-
value = stripped[idx + 1 :]
38-
3934
# If the key doesn't have the #file suffix, then add it to the bag and continue.
4035
if not key.endswith(file_suffix):
4136
data[key] = value

0 commit comments

Comments
 (0)