[tor-commits] [gettor/master] Fix bug in email parser

hiro at torproject.org hiro at torproject.org
Wed Oct 16 10:49:00 UTC 2019


commit 3c5c96c64655e7bf1ba994ca406f5855f85b5922
Author: hiro <hiro at torproject.org>
Date:   Wed Oct 16 12:48:57 2019 +0200

    Fix bug in email parser
---
 gettor/parse/email.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gettor/parse/email.py b/gettor/parse/email.py
index f1c7dc3..9660863 100644
--- a/gettor/parse/email.py
+++ b/gettor/parse/email.py
@@ -198,9 +198,8 @@ class EmailParser(object):
         return request
 
 
-    def check_num_requests(self, request_id, request_service, limit):
-        hid = hashlib.sha256(request_id.encode('utf-8'))
-        # check limits first
+    def check_num_requests(self, request_id, hid, request_service, limit):
+        # check limit first
         num_requests = limit
 
         if hid.hexdigest() == self.settings.get('test_hid'):
@@ -232,6 +231,7 @@ class EmailParser(object):
         email_requests_limit = self.settings.get("email_requests_limit")
         now_str = datetime.now().strftime("%Y%m%d%H%M%S")
         dbname = self.settings.get("dbname")
+        hid = hashlib.sha256(request['id'].encode('utf-8'))
         conn = SQLite3(dbname)
 
         if request["command"]:
@@ -239,7 +239,7 @@ class EmailParser(object):
                 "Found request for {}.".format(request['command']),
                 system="email parser"
             )
-            if self.check_num_requests(request['id'], request['service'], email_requests_limit):
+            if self.check_num_requests(request['id'], hid, request['service'], email_requests_limit):
                 conn.new_request(
                     id=request['id'],
                     command=request['command'],



More information about the tor-commits mailing list