diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index d540971c3b4..3c124f740f4 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -29,7 +29,7 @@ from osv import fields import tools from tools.translate import _ from tools.html_sanitize import html_sanitize -from tools import html2plaintext +from tools import html2plaintext, append_content_to_html from urllib import quote as quote _logger = logging.getLogger(__name__) @@ -322,13 +322,12 @@ class email_template(osv.osv): template.model, res_id, context=context) \ or False - if values['body_html']: - values['body'] = html_sanitize(values['body_html']) - values['body_text'] = html2plaintext(values['body_html']) - if template.user_signature: signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature - values['body'] += '\n\n' + signature + values['body_html'] = append_content_to_html(values['body_html'], signature) + + if values['body_html']: + values['body'] = html_sanitize(values['body_html']) values.update(mail_server_id = template.mail_server_id.id or False, auto_delete = template.auto_delete, diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 11e726c537b..a6fb2a00646 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -100,8 +100,6 @@ class mail_compose_message(osv.osv_memory): values.update(use_template=use_template, template_id=template_id) - print 'returning ', values - return {'value': values} def toggle_template(self, cr, uid, ids, context=None): diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 9646744fae8..9205aa0b933 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -98,12 +98,7 @@ class mail_notification(osv.Model): body_html = msg.body signature = msg.author_id and msg.author_id.user_ids[0].signature or '' if signature: - signature_block = u'\n
%s
\n' % signature - insertion_point = body_html.find('') - if insertion_point > -1: - body_html = body_html[:insertion_point] + signature_block + body_html[insertion_point:] - else: - body_html += signature_block + body_html = tools.append_content_to_html(body_html, signature) towrite = { 'mail_message_id': msg.id, diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index e5f36156e0b..99f6f187428 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -460,29 +460,15 @@ class mail_thread(osv.Model): continue # 2) text/plain ->
                 if part.get_content_type() == 'text/plain' and (not alternative or not body):
-                    insertion_point = body.find('')
-                    # plain text is wrapped in 
 to preserve formatting
-                    text = u'
%s
' % tools.ustr(part.get_payload(decode=True), - encoding, errors='replace') - if insertion_point != -1: - body = body[:insertion_point] + text + body[insertion_point:] - else: - body += text + body = tools.append_content_to_html(body, tools.ustr(part.get_payload(decode=True), + encoding, errors='replace')) # 3) text/html -> raw elif part.get_content_type() == 'text/html': html = tools.ustr(part.get_payload(decode=True), encoding, errors='replace') if alternative: body = html - # force tag to lowercase, for easier matching - body = re.sub(r'(?i)', r'', body) else: - # strip enclosing html/body tags and append to existing body - html = re.sub(r'(?i)(|)', '', html) - insertion_point = body.find('') - if insertion_point != -1: - body = body[:insertion_point] + html + body[insertion_point:] - else: - body += html + body = tools.append_content_to_html(body, html, plaintext=False) # 4) Anything else -> attachment else: attachments.append((filename or 'attachment', part.get_payload(decode=True)))