Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ Common
(#2152)
[Miguel Caballer - @micafer]

- [Utils] Fix ``str2dicts`` turning a line without a value, such as ``vnc``,
into a bogus ``{"vn": "vnc"}`` entry. The check for a missing space compared
the ``str.find`` result against 0 instead of -1. Such lines are now skipped
as intended. This affects responses parsed by the CloudSigma 1.0 driver.
(#2246)
[@aad1tyaaaaa]

- [Utils] Fix ``is_valid_ip_address`` raising ``ValueError`` instead of
returning ``False`` for an address containing an embedded null byte
(e.g. ``"1.2.3.4\x00"``). ``socket.inet_pton`` raises ``ValueError`` rather
Expand Down
4 changes: 4 additions & 0 deletions libcloud/test/compute/test_cloudsigma_v1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ def test_str2dicts(self):
result = str2dicts(string)
self.assertEqual(len(result), 2)

def test_str2dicts_skips_lines_without_value(self):
result = str2dicts("cpu 1100\nvnc\nmem 640")
self.assertEqual(result, [{"cpu": "1100", "mem": "640"}])

def test_str2list(self):
string = "ip 1.2.3.4\nip 1.2.3.5\nip 1.2.3.6"
result = str2list(string)
Expand Down
2 changes: 1 addition & 1 deletion libcloud/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def str2dicts(data):

whitespace = line.find(" ")

if not whitespace:
if whitespace == -1:
continue

key = line[0:whitespace]
Expand Down