[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Blank inputs cause server descriptor parsing to fail
commit 5488849baaf2402a8a315d9d474dc69207b2e6ef
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Thu Dec 20 11:47:34 2018 -0800
Blank inputs cause server descriptor parsing to fail
Honestly I'm not digging in too much, but DocTor has started providing
me with notifications of...
Unable to retrieve the present server descriptors...
source: http://204.13.164.118:80/tor/server/all
time: 12/20/2018 11:44
error: Content conform to being a server descriptor:
We strip annotation whitespace if we have descritor content to parse but didn't
if we didnn't. No reason I can think of to not do so in both cases.
---
stem/descriptor/server_descriptor.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 89b80d0a..98300775 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -195,6 +195,9 @@ def _parse_file(descriptor_file, is_bridge = False, validate = False, **kwargs):
while True:
annotations = _read_until_keywords('router', descriptor_file)
+ annotations = map(bytes.strip, annotations) # strip newlines
+ annotations = map(stem.util.str_tools._to_unicode, annotations) # convert to unicode
+ annotations = list(filter(lambda x: x != '', annotations)) # drop any blanks
if not is_bridge:
descriptor_content = _read_until_keywords('router-signature', descriptor_file)
@@ -210,9 +213,6 @@ def _parse_file(descriptor_file, is_bridge = False, validate = False, **kwargs):
if descriptor_content[0].startswith(b'@type'):
descriptor_content = descriptor_content[1:]
- # strip newlines from annotations
- annotations = list(map(bytes.strip, annotations))
-
descriptor_text = bytes.join(b'', descriptor_content)
if is_bridge:
@@ -221,8 +221,7 @@ def _parse_file(descriptor_file, is_bridge = False, validate = False, **kwargs):
yield RelayDescriptor(descriptor_text, validate, annotations, **kwargs)
else:
if validate and annotations:
- orphaned_annotations = stem.util.str_tools._to_unicode(b'\n'.join(annotations))
- raise ValueError('Content conform to being a server descriptor:\n%s' % orphaned_annotations)
+ raise ValueError('Content conform to being a server descriptor:\n%s' % '\n'.join(annotations))
break # done parsing descriptors
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits