From 35fb39a353d212b29fbca953832064af202b72f4 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Wed, 14 Apr 2010 16:05:23 +0200 Subject: [PATCH] [FIX] mailgate unicode bzr revid: al@openerp.com-20100414140523-2oqxcpfw3u4zr4o2 --- .../scripts/openerp_mailgate/openerp_mailgate.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py b/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py index 1417aa71ddf..497f1014eb9 100755 --- a/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py +++ b/addons/crm/scripts/openerp_mailgate/openerp_mailgate.py @@ -67,9 +67,9 @@ def html2plaintext(html, body_id=None, encoding='utf-8'): soup = BeautifulSoup(html, parseOnlyThese=strainer, fromEncoding=encoding) for link in soup.findAll('a'): - title = link.renderContents() + title = unicode(link) for url in [x[1] for x in link.attrs if x[0]=='href']: - urls.append(dict(url=url, tag=str(link), title=title)) + urls.append(dict(url=url, tag=unicode(link), title=title)) html = unicode(soup) @@ -162,12 +162,9 @@ class email_parser(object): if charset: try: return s.decode(charset) - except UnicodeError: - pass - try: - return s.decode('ascii') - except UnicodeError: - return s + except UnicodeError: + pass + return s.decode('latin1') def _decode_header(self, s): from email.Header import decode_header