Mercurial > p > roundup > code
diff roundup/mailgw.py @ 3415:4a228402b810
Handle invalidly-specified charsets in incoming email
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 28 Sep 2005 05:48:23 +0000 |
| parents | 4f3285913a8c |
| children | 07c696890f55 |
line wrap: on
line diff
--- a/roundup/mailgw.py Wed Sep 28 05:42:23 2005 +0000 +++ b/roundup/mailgw.py Wed Sep 28 05:48:23 2005 +0000 @@ -72,7 +72,7 @@ an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.166 2005-06-24 07:16:01 richard Exp $ +$Id: mailgw.py,v 1.167 2005-09-28 05:48:23 richard Exp $ """ __docformat__ = 'restructuredtext' @@ -223,8 +223,9 @@ # Encode message to unicode charset = rfc2822.unaliasCharset(self.getparam("charset")) if charset: - # Do conversion only if charset specified - edata = unicode(data, charset).encode('utf-8') + # Do conversion only if charset specified - handle + # badly-specified charsets + edata = unicode(data, charset, 'replace').encode('utf-8') # Convert from dos eol to unix edata = edata.replace('\r\n', '\n') else:
