summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_template.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/models/mail_template.py')
-rw-r--r--addons/mail/models/mail_template.py39
1 files changed, 1 insertions, 38 deletions
diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py
index 2407e58fdbd..17cea52deac 100644
--- a/addons/mail/models/mail_template.py
+++ b/addons/mail/models/mail_template.py
@@ -315,45 +315,8 @@ class MailTemplate(models.Model):
# ----------------------------------------
@api.model
- def _replace_local_links(self, html):
- """ Post-processing of html content to replace local links to absolute
- links, using web.base.url as base url. """
- if not html:
- return html
-
- # form a tree
- root = lxml.html.fromstring(html)
- if not len(root) and root.text is None and root.tail is None:
- html = u'<div>%s</div>' % html
- root = lxml.html.fromstring(html, encoding='unicode')
-
- base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url')
- base = urls.url_parse(base_url)
-
- def _process_link(url):
- new_url = urls.url_parse(url)
- if new_url.scheme and (new_url.netloc or new_url.scheme == 'mailto'):
- return url
- return new_url.replace(scheme=base.scheme, netloc=base.netloc).to_url()
-
- # check all nodes, replace :
- # - img src -> check URL
- # - a href -> check URL
- for node in root.iter():
- if node.tag == 'a' and node.get('href'):
- node.set('href', _process_link(node.get('href')))
- elif node.tag == 'img' and not node.get('src', 'data').startswith(u'data'):
- node.set('src', _process_link(node.get('src')))
-
- html = lxml.html.tostring(root, pretty_print=False, method='html', encoding='unicode')
- # this is ugly, but lxml/etree tostring want to put everything in a 'div' that breaks the editor -> remove that
- if html.startswith(u'<div>') and html.endswith(u'</div>'):
- html = html[5:-6]
- return html
-
- @api.model
def render_post_process(self, html):
- html = self._replace_local_links(html)
+ html = self.env['mail.thread']._replace_local_links(html)
return html
@api.model