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

Proposed by Kuldeep Joshi(OpenERP)
Status: Merged
Approved by: Raphael Collet (OpenERP)
Approved revision: no longer in the source branch.
Merged at revision: 6679
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-bug-921442-kjo
Merge into: lp:openobject-addons
Diff against target: 46 lines (+6/-4)
2 files modified
base_action_rule/base_action_rule.py (+3/-2)
crm/crm_action_rule.py (+3/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-bug-921442-kjo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+92248@code.launchpad.net

Description of the change

Encoding trouble in mail_message parsing and base_action_rule processin

To post a comment you must log in.
Revision history for this message
Jigar A. (ifixthat) wrote :

First part of the bug which is "Parsing the rules (base_action_rule) breaks if the regexp or the name of the resource (model) has some non-string char". And Technically it is valid bug, we have reproduced the bug and I am adding step here for the same :

Test case :

- Install Module crm.
- Create 'Automated Action' under Settings/Customization/Automated Actions/Automated Actions for the model crm.lead.
   - Now Supply non-character (e.g. "ààààààà") string under following two field :
   - First field Under Conditions on Model Fields Section, 'Regex on Resource Name '
   - Second field Under Section 'Condition on Communication History' Regular Expression on Case History
- Now, When Automated action with non-character string will be trigger we will have traceback on server saying :
 File "/home/jam/rdtools/addons/trunk-calendar-phase2/base_action_rule/base_action_rule.py", line 372, in do_check
    ptrn = re.compile(str(reg_name))
    UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)
    2012-02-15 05:55:44,278 4176 ERROR ? openerp.netsvc: ascii
    ààààààà
   0
   7
    ordinal not in range(128)
(You can see the Video on Comment#13 on bug post for the same)

Thank You.

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

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-09 11:20:26 +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-09 11:20:26 +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

Subscribers

People subscribed via source and target branches

to all changes: