Merge lp://qastaging/~sylvain-calador/poweremail/decode-attachments into lp://qastaging/poweremail/trunk

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

Hi,

This branch add internationalized subject decoding(based on Jordi Esteve work) which is missing when email has attachments.

Best regards,

Sylvain

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

Thanks again

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 15:20:28 +0000
4@@ -464,10 +464,10 @@
5 att_ids = []
6 for each in parsed_mail['attachments']:#Get each attachment
7 new_att_vals = {
8- 'name':mail['subject'] + '(' + each[0] + ')',
9+ 'name':self.decode_header_text(mail['subject']) + '(' + each[0] + ')',
10 'datas':base64.b64encode(each[2] or ''),
11 'datas_fname':each[1],
12- 'description':(mail['subject'] or 'No Subject') + " [Type:" + (each[0] or 'Unknown') + ", Filename:" + (each[1] or 'No Name') + "]",
13+ 'description':(self.decode_header_text(mail['subject']) or 'No Subject') + " [Type:" + (each[0] or 'Unknown') + ", Filename:" + (each[1] or 'No Name') + "]",
14 'res_model':'poweremail.mailbox',
15 'res_id':id
16 }
17@@ -682,8 +682,11 @@
18 return text
19 p = re.compile("(=\?.*?\?.\?.*?\?=)")
20 text2 = ''
21- for t2 in p.split(text):
22- text2 += ''.join([s.decode(t or 'ascii') for (s, t) in decode_header(t2)]).encode('utf-8')
23+ try:
24+ for t2 in p.split(text):
25+ text2 += ''.join([s.decode(t or 'ascii') for (s, t) in decode_header(t2)]).encode('utf-8')
26+ except:
27+ return text
28 return text2
29
30 poweremail_core_accounts()