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

[tor-commits] [bridgedb/develop] Fix a bug where incoming unicode emails caused logging errors.



commit 891b75afc307b74173aa37095527f531e47bc4a6
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Sat Jun 7 02:11:33 2014 +0000

    Fix a bug where incoming unicode emails caused logging errors.
    
    The stupid Python stdlib logging module doesn't handle unicode at
    all. If debugging is turned on, and SAFELOGGING is disabled, the
    incoming emails are logged. If they have any unicode characters,
    processing of the emails stops due to UnicodeDecodeErrors.
---
 lib/bridgedb/email/server.py |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/bridgedb/email/server.py b/lib/bridgedb/email/server.py
index 94405ea..f57b957 100644
--- a/lib/bridgedb/email/server.py
+++ b/lib/bridgedb/email/server.py
@@ -174,7 +174,13 @@ class SMTPMessage(object):
         else:
             self.lines.append(line)
         if not safelog.safe_logging:
-            logging.debug("> %s", line.rstrip("\r\n"))
+            try:
+                logging.debug("> %s", line.rstrip("\r\n"))
+            except UnicodeError:  # pragma: no cover
+                pass
+            except Exception as error:  # pragma: no cover
+                logging.error("Error while trying to log incoming email")
+                logging.exception(error)
 
     def eomReceived(self):
         """Tell the :ivar:`responder` to reply when we receive an EOM."""



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