From d1c40ad8828f10bdf4e996029232bb1709ea1187 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 10 Mar 2023 12:53:00 +0100 Subject: [PATCH] Test if anchor has href attribute before converting it It is valid HTML to have anchor without href attribute. Closes #12134 (grafted from f3a2d9b2258d6004fffc5431136bd36b010b7f9b) --HG-- branch : 6.0 --- modules/marketing_automation/marketing_automation.py | 2 +- modules/marketing_email/marketing.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/marketing_automation/marketing_automation.py b/modules/marketing_automation/marketing_automation.py index 6cf07809a6..1e3c95156f 100644 --- a/modules/marketing_automation/marketing_automation.py +++ b/modules/marketing_automation/marketing_automation.py @@ -567,7 +567,7 @@ class Activity(ModelSQL, ModelView): for kind, data, pos in stream: if kind is START: tag, attrs = data - if tag == 'a': + if tag == 'a' and attrs.get('href'): href = attrs.get('href') attrs -= 'href' if href.startswith('unsubscribe'): diff --git a/modules/marketing_email/marketing.py b/modules/marketing_email/marketing.py index 7242cd6034..470fa7fec9 100644 --- a/modules/marketing_email/marketing.py +++ b/modules/marketing_email/marketing.py @@ -425,7 +425,7 @@ class Message(Workflow, ModelSQL, ModelView): for kind, data, pos in stream: if kind is START: tag, attrs = data - if tag == 'a': + if tag == 'a' and attrs.get('href'): href = attrs.get('href') attrs -= 'href' href = short(href, str(message))