From 303c895a86d1b8a951801c6f08b99d26c5dc0dd1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 9 Mar 2021 10:12:17 +0000 Subject: [PATCH] [FIX] link_tracker: markuping in link shortening `href` is `href="...`, so if the input is a Markup object it will get escaped on `html.replace`, which means it will not actually match the text we're looking for. Therefore mark it as `Markup`, because that's essentially what it is. This should have no effect if `html` is an `str`. --- addons/link_tracker/models/mail_render_mixin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/link_tracker/models/mail_render_mixin.py b/addons/link_tracker/models/mail_render_mixin.py index 50ea3315676..47d0f274307 100644 --- a/addons/link_tracker/models/mail_render_mixin.py +++ b/addons/link_tracker/models/mail_render_mixin.py @@ -3,6 +3,7 @@ import re +import markupsafe from werkzeug import urls, utils from odoo import api, models, tools @@ -35,7 +36,7 @@ class MailRenderMixin(models.AbstractModel): base_url = base_url or self.env['ir.config_parameter'].sudo().get_param('web.base.url') short_schema = base_url + '/r/' for match in re.findall(tools.HTML_TAG_URL_REGEX, html): - href = match[0] + href = markupsafe.Markup(match[0]) long_url = match[1] label = (match[3] or '').strip()