[tor-commits] [bridgedb/master] Import rfc822 directly instead of over detour.

phw at torproject.org phw at torproject.org
Thu Oct 3 23:01:03 UTC 2019


commit 15b8e0df097e2cf98c13faf6aabc3236520fa14b
Author: Philipp Winter <phw at nymity.ch>
Date:   Thu Sep 12 08:59:50 2019 -0700

    Import rfc822 directly instead of over detour.
    
    Some of our code got the rfc822 module over a detour, by importing it
    through twisted.mail.smtp.  This is dangerous and only works if
    twisted.mail.smtp actually does import rfc822 -- which newer versions
    stopped doing.  We're fixing this by doing what we should have been
    doing all along: importing the module ourselves.
---
 bridgedb/distributors/email/server.py | 3 ++-
 bridgedb/test/test_email_dkim.py      | 2 +-
 bridgedb/test/test_email_server.py    | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/bridgedb/distributors/email/server.py b/bridgedb/distributors/email/server.py
index 229f118..8bd4b36 100644
--- a/bridgedb/distributors/email/server.py
+++ b/bridgedb/distributors/email/server.py
@@ -52,6 +52,7 @@ from __future__ import unicode_literals
 import logging
 import io
 import socket
+import rfc822
 
 from twisted.internet import defer
 from twisted.internet import reactor
@@ -254,7 +255,7 @@ class SMTPMessage(object):
         for line in self.lines:
             rawMessage.writelines(unicode(line.decode('utf8')) + u'\n')
         rawMessage.seek(0)
-        return smtp.rfc822.Message(rawMessage)
+        return rfc822.Message(rawMessage)
 
 
 class SMTPIncomingDelivery(smtp.SMTP):
diff --git a/bridgedb/test/test_email_dkim.py b/bridgedb/test/test_email_dkim.py
index dc4c53b..be34370 100644
--- a/bridgedb/test/test_email_dkim.py
+++ b/bridgedb/test/test_email_dkim.py
@@ -12,8 +12,8 @@
 """Unittests for the :mod:`bridgedb.distributors.email.dkim` module."""
 
 import io
+import rfc822
 
-from twisted.mail.smtp import rfc822
 from twisted.trial import unittest
 
 from bridgedb.distributors.email import dkim
diff --git a/bridgedb/test/test_email_server.py b/bridgedb/test/test_email_server.py
index edf2539..bc331f4 100644
--- a/bridgedb/test/test_email_server.py
+++ b/bridgedb/test/test_email_server.py
@@ -16,6 +16,7 @@ from __future__ import print_function
 import socket
 import string
 import types
+import rfc822
 
 from twisted.python import log
 from twisted.internet import defer
@@ -25,7 +26,6 @@ from twisted.mail.smtp import SMTPBadRcpt
 from twisted.mail.smtp import SMTPBadSender
 from twisted.mail.smtp import User
 from twisted.mail.smtp import Address
-from twisted.mail.smtp import rfc822
 from twisted.test import proto_helpers
 from twisted.trial import unittest
 





More information about the tor-commits mailing list