From 3228694bddff75a9c04504f09b6da56c5f5a5647 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 18 Jul 2017 18:36:21 +0200 Subject: [PATCH] [FIX] mass_mailing: only track shorten links It may happen that some mails attached to a mailing contains non shorten links. --- addons/mass_mailing/models/mass_mailing.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py index 5c8d84f76a4..10fd678db20 100644 --- a/addons/mass_mailing/models/mass_mailing.py +++ b/addons/mass_mailing/models/mass_mailing.py @@ -4,6 +4,7 @@ from datetime import datetime from dateutil import relativedelta import random import re +from urlparse import urlparse from openerp import tools from openerp import models, api, _ @@ -871,16 +872,13 @@ class MailMail(models.Model): @api.model def send_get_mail_body(self, mail, partner=None): """Override to add Statistic_id in shorted urls """ - - links_blacklist = ['/unsubscribe_from_list'] - if mail.mailing_id and mail.body_html and mail.statistics_ids: for match in re.findall(URL_REGEX, mail.body_html): - href = match[0] url = match[1] - - if not [s for s in links_blacklist if s in href]: + parsed = urlparse(url, scheme='http') + + if parsed.scheme.startswith('http') and parsed.path.startswith('/r/'): new_href = href.replace(url, url + '/m/' + str(mail.statistics_ids[0].id)) mail.body_html = mail.body_html.replace(href, new_href)