diff options
| author | Antonio Espinosa <antespi@gmail.com> | 2015-12-14 12:37:02 +0100 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2015-12-16 15:17:09 +0100 |
| commit | fc3c0b22f9d3a16a0b7aefde68a278dd9fff9789 (patch) | |
| tree | 82cbda3ef52a99946f343077ae185a6f727e18fe /addons/mass_mailing/models/mail_mail.py | |
| parent | 5425316eff19e7ae716aafdb730c92d1b3ea2abb (diff) | |
[FIX] mass_mailing: absolute URLs to email images
Partial backport of 9.0 commit a14f89c8 to 8.0
<base href=""> are not well supported in some webmails
Replace absolute URLs by full path appending the domain.
Closes #10062
Diffstat (limited to 'addons/mass_mailing/models/mail_mail.py')
| -rw-r--r-- | addons/mass_mailing/models/mail_mail.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/addons/mass_mailing/models/mail_mail.py b/addons/mass_mailing/models/mail_mail.py index 651d8f07729..c2775ad019b 100644 --- a/addons/mass_mailing/models/mail_mail.py +++ b/addons/mass_mailing/models/mail_mail.py @@ -21,6 +21,7 @@ import urlparse import werkzeug.urls +import re from openerp.tools.translate import _ from openerp import tools @@ -80,6 +81,14 @@ class MailMail(osv.Model): base = "<base href='%s'>" % domain body = tools.append_content_to_html(base, body, plaintext=False, container_tag='div') + # resolve relative image url to absolute for outlook.com + def _sub_relative2absolute(match): + return match.group(1) + urlparse.urljoin(domain, match.group(2)) + # Regex: https://regex101.com/r/aE8uG5/3 + body = re.sub('(<img(?=\s)[^>]*\ssrc=["\'])(/[^/][^"\']+)', _sub_relative2absolute, body) + # Regex: https://regex101.com/r/kT3lD5/2 + body = re.sub(r'(<[^>]+\bstyle=["\'][^"\']+\burl\([\'"]?)(/[^/\'"][^\'")]+)', _sub_relative2absolute, body) + # generate tracking URL if mail.statistics_ids: tracking_url = self._get_tracking_url(cr, uid, mail, partner, context=context) |
