[tor-commits] [gettor/master] Don't assume that request has "command" key.

cohosh at torproject.org cohosh at torproject.org
Sat May 30 02:02:41 UTC 2020


commit b3de2e35ea73cc29c4744423a9abe60c9997f5a7
Author: Philipp Winter <phw at nymity.ch>
Date:   Fri May 29 16:23:19 2020 -0700

    Don't assume that request has "command" key.
    
    If GetTor deals with an autoresponder, it returns an empty request,
    which is then passed to parse_callback, which raises a KeyError because
    of request["command"]:
    
    2020-05-29 19:04:43+0000 [email parser] Error while parsing email content: [Failure instance: Traceback: <class 'KeyError'>: 'command'
            /usr/lib/python3/dist-packages/twisted/internet/defer.py:311:addCallbacks
            /usr/lib/python3/dist-packages/twisted/internet/defer.py:654:_runCallbacks
            /usr/lib/python3/dist-packages/twisted/internet/defer.py:1613:unwindGenerator
            /usr/lib/python3/dist-packages/twisted/internet/defer.py:1529:_cancellableInlineCallbacks
            --- <exception caught here> ---
            /usr/lib/python3/dist-packages/twisted/internet/defer.py:1418:_inlineCallbacks
            /srv/gettor.torproject.org/home/gettor/gettor/parse/email.py:256:parse_callback
            ].
    
    This is a fixup of: <https://bugs.torproject.org/34286>
---
 gettor/parse/email.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gettor/parse/email.py b/gettor/parse/email.py
index 41b34ce..fa945ba 100644
--- a/gettor/parse/email.py
+++ b/gettor/parse/email.py
@@ -253,7 +253,7 @@ class EmailParser(object):
         dbname = self.settings.get("dbname")
         test_hid = self.settings.get("test_hid")
 
-        if request["command"]:
+        if "command" in request:
 
             hid = hashlib.sha256(request['id'].encode('utf-8')).hexdigest()
             request_service = request['service']



More information about the tor-commits mailing list