commit 7df236509dca6d32d5cebb8aa0b634d3b3d962b1 Author: Damian Johnson atagar@torproject.org Date: Mon Dec 31 00:47:58 2012 -0800
Duplicate network status 'm' lines were ignored
The 'm' lines in version 3 router status entries can appear multiple times, but we were only parsing the first instance. --- stem/descriptor/router_status_entry.py | 4 +++- test/unit/descriptor/router_status_entry.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/stem/descriptor/router_status_entry.py b/stem/descriptor/router_status_entry.py index 2d02330..31458c1 100644 --- a/stem/descriptor/router_status_entry.py +++ b/stem/descriptor/router_status_entry.py @@ -312,7 +312,9 @@ class RouterStatusEntryV3(RouterStatusEntry): _parse_p_line(self, value, validate) del entries['p'] elif keyword == 'm': - _parse_m_line(self, value, validate) + for entry, _ in values: + _parse_m_line(self, entry, validate) + del entries['m']
RouterStatusEntry._parse(self, entries, validate) diff --git a/test/unit/descriptor/router_status_entry.py b/test/unit/descriptor/router_status_entry.py index 8a7e711..b0cd3b8 100644 --- a/test/unit/descriptor/router_status_entry.py +++ b/test/unit/descriptor/router_status_entry.py @@ -438,6 +438,20 @@ class TestRouterStatusEntry(unittest.TestCase): entry = RouterStatusEntryV3(content, document = mock_document) self.assertEquals(expected, entry.microdescriptor_hashes)
+ # try with multiple 'm' lines + + content = get_router_status_entry_v3(content = True) + content += "\nm 11,12 sha256=g1vx9si329muxV3tquWIXXySNOIwRGMeAESKs/v4DWs" + content += "\nm 31,32 sha512=g1vx9si329muxV3tquWIXXySNOIwRGMeAESKs/v4DWs" + + expected = [ + ([11, 12], {"sha256": "g1vx9si329muxV3tquWIXXySNOIwRGMeAESKs/v4DWs"}), + ([31, 32], {"sha512": "g1vx9si329muxV3tquWIXXySNOIwRGMeAESKs/v4DWs"}), + ] + + entry = RouterStatusEntryV3(content, document = mock_document) + self.assertEquals(expected, entry.microdescriptor_hashes) + # try without a document content = get_router_status_entry_v3({'m': "8,9,10,11,12"}, content = True) self._expect_invalid_attr(content, "microdescriptor_hashes")