[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`.
This commit is contained in:
Xavier Morel
2021-04-29 05:34:20 +00:00
parent b9f016f6c6
commit 303c895a86
@@ -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()