Merge lp://qastaging/~sylvain-calador/poweremail/header-non-ascii into lp://qastaging/poweremail/trunk

Proposed by Sylvain Calador
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~sylvain-calador/poweremail/header-non-ascii
Merge into: lp://qastaging/poweremail/trunk
Diff against target: 17 lines (+5/-2)
1 file modified
poweremail_core.py (+5/-2)
To merge this branch: bzr merge lp://qastaging/~sylvain-calador/poweremail/header-non-ascii
Reviewer Review Type Date Requested Status
Sharoon Thomas http://openlabs.co.in Approve
Review via email: mp+16639@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
Sylvain Calador (sylvain-calador) wrote :

Hi,

Great improvement from Jordi Esteve about internationalized header.

I just propose to surround the encoding stuff with try/catch to avoid
various exceptions when header is not internationalized but contains
non-ascii characters (I have sevral mail from Dell in this case, wich
give me errors like "ascii codec can't decode char at...")

Best regards,

Sylvain

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

Thanks for the contribution.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'poweremail_core.py'
2--- poweremail_core.py 2009-12-26 22:51:50 +0000
3+++ poweremail_core.py 2009-12-29 13:18:14 +0000
4@@ -682,8 +682,11 @@
5 return text
6 p = re.compile("(=\?.*?\?.\?.*?\?=)")
7 text2 = ''
8- for t2 in p.split(text):
9- text2 += ''.join([s.decode(t or 'ascii') for (s, t) in decode_header(t2)]).encode('utf-8')
10+ try:
11+ for t2 in p.split(text):
12+ text2 += ''.join([s.decode(t or 'ascii') for (s, t) in decode_header(t2)]).encode('utf-8')
13+ except:
14+ return text
15 return text2
16
17 poweremail_core_accounts()