Unverified Commit b4f15e8b authored by Isis Lovecruft's avatar Isis Lovecruft
Browse files

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).
parent 8df3fc1a
......@@ -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")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment