Merge lp:~openerp-dev/openobject-addons/trunk-bug-921442-nco into lp:openobject-addons

Proposed by Nimesh Contractor(Open ERP)
Status: Rejected
Rejected by: Olivier Dony (Odoo)
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-921442-nco
Merge into: lp:openobject-addons
Diff against target: 60 lines (+9/-4)
3 files modified
base_action_rule/base_action_rule.py (+3/-2)
crm/crm_action_rule.py (+3/-2)
mail/mail_message.py (+3/-0)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-921442-nco
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Disapprove
Raphael Collet (OpenERP) (community) Needs Information
Review via email: mp+93940@code.launchpad.net

Description of the change

Hello,

     For encoding trouble: encode the string in unicode, I have applied patch of Joël Grand-Guillaume @ CampToCamp (jgrandguillaume-c2c) and its working fine.

Thanks,
 NCO.

To post a comment you must log in.
Revision history for this message
Raphael Collet (OpenERP) (rco-openerp) wrote :

Thanks!
Raphael

review: Approve
Revision history for this message
Raphael Collet (OpenERP) (rco-openerp) wrote :

Oh, I just noticed that you changed history.name into history.subject.
Why?

review: Needs Information
Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote :

The fix with the missing ustr() call is fine, but it was already correct in the branch from kjo, so I'll merge that in the 6.1 branch separately.

The other fix from Joel is unfortunately not correct for multiple reasons:

1. There is still no proper way to reproduce it that does not involve injecting the error directly in the OpenERP code. We need a way to reproduce this by passing an email message to the parse_message() method, anything else is flawed: when you directly patch the code to produce an error you can do anything that is impossible to trigger in real cases.

2. This is not a proper way to avoid unicode errors. When you call unicode(txt, errors='ignore') you *explicitly* drop anything that is not ASCII within `txt` in the process, because anything else is considered invalid in the default ASCII encoding! e.g.:
  >>> unicode('abcdé', errors='ignore')
  u'abcd'
A cleaner way to do it would be to use errors='replace' and pass the original encoding so only invalid bytes *in the specified encoding* will be replaced. i.e.
  >>> unicode('abcdé' + chr(255), 'utf8', errors='replace')
  u'abcd\xe9\ufffd''

3. This patch is attempting to spot-patch just one out of the dozens of many conversions that are performed in the parse_message() method, which makes little sense. If the code is supposed to be tolerant to malformed email parts, it should not do it for only of the possible places that can be malformed.

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'base_action_rule/base_action_rule.py'
--- base_action_rule/base_action_rule.py 2011-12-27 09:27:00 +0000
+++ base_action_rule/base_action_rule.py 2012-02-21 09:12:25 +0000
@@ -28,6 +28,7 @@
28import re28import re
29import time29import time
30import tools30import tools
31from openerp.loglevels import ustr
3132
3233
33def get_datetime(date_field):34def get_datetime(date_field):
@@ -369,8 +370,8 @@
369 reg_name = action.regex_name370 reg_name = action.regex_name
370 result_name = True371 result_name = True
371 if reg_name:372 if reg_name:
372 ptrn = re.compile(str(reg_name))373 ptrn = re.compile(ustr(reg_name))
373 _result = ptrn.search(str(obj.name))374 _result = ptrn.search(ustr(obj.name))
374 if not _result:375 if not _result:
375 result_name = False376 result_name = False
376 regex_n = not reg_name or result_name377 regex_n = not reg_name or result_name
377378
=== modified file 'crm/crm_action_rule.py'
--- crm/crm_action_rule.py 2011-12-20 15:29:31 +0000
+++ crm/crm_action_rule.py 2012-02-21 09:12:25 +0000
@@ -27,6 +27,7 @@
27from osv import osv27from osv import osv
2828
29import crm29import crm
30from openerp.loglevels import ustr
3031
31class base_action_rule(osv.osv):32class base_action_rule(osv.osv):
32 """ Base Action Rule """33 """ Base Action Rule """
@@ -73,9 +74,9 @@
73 regex = action.regex_history74 regex = action.regex_history
74 if regex:75 if regex:
75 res = False76 res = False
76 ptrn = re.compile(str(regex))77 ptrn = re.compile(ustr(regex))
77 for history in obj.message_ids:78 for history in obj.message_ids:
78 _result = ptrn.search(str(history.name))79 _result = ptrn.search(ustr(history.subject))
79 if _result:80 if _result:
80 res = True81 res = True
81 break82 break
8283
=== modified file 'mail/mail_message.py'
--- mail/mail_message.py 2012-01-31 13:36:57 +0000
+++ mail/mail_message.py 2012-02-21 09:12:25 +0000
@@ -453,6 +453,9 @@
453453
454 msg['body_text'] = body454 msg['body_text'] = body
455 msg['attachments'] = attachments455 msg['attachments'] = attachments
456 # For encoding trouble: encode the string in unicode, ignoring unkown byte
457 if 'body_html' in msg and isinstance(msg['body_html'],str):
458 msg['body_html'] = unicode(msg['body_html'], errors='ignore')
456459
457 # for backwards compatibility:460 # for backwards compatibility:
458 msg['body'] = msg['body_text']461 msg['body'] = msg['body_text']

Subscribers

People subscribed via source and target branches

to all changes: