[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Trailing newline broke descriptor downloads



commit 1e1f3665aebb521acbcf332dbf752f1a815c62cf
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Jul 21 18:38:51 2020 -0700

    Trailing newline broke descriptor downloads
    
    I rewrote stem.descriptor.remote's download code for our asyncio migration.
    When retrieving server descriptors we ended with a double newline ('\n\n')
    which caused our parser to think that there are two descriptors, the second of
    which is '\n'. This in turned broke validation with...
    
      ======================================================================
      FAIL: test_using_authorities
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/atagar/Desktop/stem/test/integ/descriptor/remote.py", line 118, in test_using_authorities
          descriptors = list(query.run())
        File "/home/atagar/Desktop/stem/stem/util/__init__.py", line 363, in _run_async_method
          return future.result()
        File "/home/atagar/Python-3.7.0/Lib/concurrent/futures/_base.py", line 432, in result
          return self.__get_result()
      ValueError: Descriptor must have a 'router' entry
    
      During handling of the above exception, another exception occurred:
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/stem/test/require.py", line 60, in wrapped
          return func(self, *args, **kwargs)
        File "/home/atagar/Desktop/stem/test/require.py", line 75, in wrapped
          return func(self, *args, **kwargs)
        File "/home/atagar/Desktop/stem/test/integ/descriptor/remote.py", line 120, in test_using_authorities
          self.fail('Unable to use %s (%s:%s, %s): %s' % (authority.nickname, authority.address, authority.dir_port, type(exc), exc))
      AssertionError: Unable to use moria1 (128.31.0.39:9131, <class 'ValueError'>): Descriptor must have a 'router' entry
---
 stem/descriptor/remote.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py
index 2912134c..ff4b1403 100644
--- a/stem/descriptor/remote.py
+++ b/stem/descriptor/remote.py
@@ -1003,11 +1003,11 @@ def _http_body_and_headers(data: bytes) -> Tuple[bytes, Dict[str, str]]:
   encoding = headers.get('Content-Encoding')
 
   if encoding == 'deflate':
-    return stem.descriptor.Compression.GZIP.decompress(body_data), headers
+    return stem.descriptor.Compression.GZIP.decompress(body_data).rstrip(), headers
 
   for compression in stem.descriptor.Compression:
     if encoding == compression.encoding:
-      return compression.decompress(body_data), headers
+      return compression.decompress(body_data).rstrip(), headers
 
   raise ValueError("'%s' is an unrecognized encoding" % encoding)
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits