commit b4f15e8bbf489db830591c81181a4d69beb9dde5 Author: Isis Lovecruft isis@torproject.org Date: Fri Jul 25 05:24:44 2014 +0000
Fix unhandled UnicodeDecodeError in call to logger for emails.
This makes the calls to log incoming emails (if debugging is enabled) less strict about unicode encoding, and also catches UnicodeDecodeErrors (in addition to UnicodeErrors). --- lib/bridgedb/email/server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/bridgedb/email/server.py b/lib/bridgedb/email/server.py index 194e74a..53105f5 100644 --- a/lib/bridgedb/email/server.py +++ b/lib/bridgedb/email/server.py @@ -183,8 +183,9 @@ class SMTPMessage(object): self.lines.append(line) if not safelog.safe_logging: try: - logging.debug("> %s", line.rstrip("\r\n").encode('utf-8')) - except UnicodeError: # pragma: no cover + ln = line.rstrip("\r\n").encode('utf-8', 'replace') + logging.debug("> %s" % ln) + except (UnicodeError, UnicodeDecodeError): # pragma: no cover pass except Exception as error: # pragma: no cover logging.error("Error while trying to log incoming email")
tor-commits@lists.torproject.org