Merge lp:~openerp-dev/openobject-server/saas-3-opw-605315-acl into lp:~openerp/openobject-server/saas-3

Proposed by Anaël Closson (openerp)
Status: Merged
Merged at revision: 5117
Proposed branch: lp:~openerp-dev/openobject-server/saas-3-opw-605315-acl
Merge into: lp:~openerp/openobject-server/saas-3
Diff against target: 43 lines (+8/-2)
1 file modified
openerp/tools/mail.py (+8/-2)
To merge this branch: bzr merge lp:~openerp-dev/openobject-server/saas-3-opw-605315-acl
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Review via email: mp+215889@code.launchpad.net

Description of the change

The html editor modifies mako instruction not inside html tags.
This keep modifies html sanitisation so that
 - comments are kept in the sanitisation process
 - they are considered as inside html tags by the html editor, hence not modified

This is particularly needed when a template generates rows in a html table, the processing instructions should be added around "<tr></tr>". Any modifications in the template before sending the e-mail break it.

To post a comment you must log in.
Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

LGMT, merged in saas-3

revno: 5117 [merge]
revision-id: <email address hidden>

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openerp/tools/mail.py'
2--- openerp/tools/mail.py 2014-02-19 14:06:17 +0000
3+++ openerp/tools/mail.py 2014-04-15 14:45:57 +0000
4@@ -45,7 +45,7 @@
5 tags_to_remove = ['html', 'body', 'font']
6
7 # allow new semantic HTML5 tags
8-allowed_tags = clean.defs.tags | frozenset('article section header footer hgroup nav aside figure main'.split())
9+allowed_tags = clean.defs.tags | frozenset('article section header footer hgroup nav aside figure main'.split() + [etree.Comment])
10 safe_attrs = clean.defs.safe_attrs | frozenset(
11 ['style',
12 'data-oe-model', 'data-oe-id', 'data-oe-field', 'data-oe-type', 'data-oe-expression', 'data-oe-translate', 'data-oe-nodeid',
13@@ -70,6 +70,8 @@
14 'forms': True, # remove form tags
15 'remove_unknown_tags': False,
16 'allow_tags': allowed_tags,
17+ 'comments': False,
18+ 'processing_instructions' : False
19 }
20 if etree.LXML_VERSION >= (2, 3, 1):
21 # kill_tags attribute has been added in version 2.3.1
22@@ -339,10 +341,14 @@
23 overlength_section_count = 0
24 cur_char_nbr = 0
25 for node in root.iter():
26+ # comments do not need processing
27+ if node.tag == etree.Comment:
28+ continue
29 # do not take into account multiple spaces that are displayed as max 1 space in html
30 node_text = ' '.join((node.text and node.text.strip(' \t\r\n') or '').split())
31
32 # root: try to tag the client used to write the html
33+ # note: bug in node.get(value, default) for HtmlComments, default never returned
34 if 'WordSection1' in node.get('class', '') or 'MsoNormal' in node.get('class', ''):
35 root.set('msoffice', '1')
36 if 'SkyDrivePlaceholder' in node.get('class', '') or 'SkyDrivePlaceholder' in node.get('id', ''):
37@@ -657,4 +663,4 @@
38 # sometimes returns emails without at least '@'. The '@'
39 # is strictly required in RFC2822's `addr-spec`.
40 if addr[1]
41- if '@' in addr[1]]
42\ No newline at end of file
43+ if '@' in addr[1]]

Subscribers

People subscribed via source and target branches