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
1=== modified file 'base_action_rule/base_action_rule.py'
2--- base_action_rule/base_action_rule.py 2011-12-27 09:27:00 +0000
3+++ base_action_rule/base_action_rule.py 2012-02-09 11:20:26 +0000
4@@ -28,6 +28,7 @@
5 import re
6 import time
7 import tools
8+from openerp.loglevels import ustr
9
10
11 def get_datetime(date_field):
12@@ -369,8 +370,8 @@
13 reg_name = action.regex_name
14 result_name = True
15 if reg_name:
16- ptrn = re.compile(str(reg_name))
17- _result = ptrn.search(str(obj.name))
18+ ptrn = re.compile(ustr(reg_name))
19+ _result = ptrn.search(ustr(obj.name))
20 if not _result:
21 result_name = False
22 regex_n = not reg_name or result_name
23
24=== modified file 'crm/crm_action_rule.py'
25--- crm/crm_action_rule.py 2011-12-20 15:29:31 +0000
26+++ crm/crm_action_rule.py 2012-02-09 11:20:26 +0000
27@@ -27,6 +27,7 @@
28 from osv import osv
29
30 import crm
31+from openerp.loglevels import ustr
32
33 class base_action_rule(osv.osv):
34 """ Base Action Rule """
35@@ -73,9 +74,9 @@
36 regex = action.regex_history
37 if regex:
38 res = False
39- ptrn = re.compile(str(regex))
40+ ptrn = re.compile(ustr(regex))
41 for history in obj.message_ids:
42- _result = ptrn.search(str(history.name))
43+ _result = ptrn.search(ustr(history.subject))
44 if _result:
45 res = True
46 break

Subscribers

People subscribed via source and target branches

to all changes: