From ffda905ba74b28be5c213f4b3cb6acb1d97cd49a Mon Sep 17 00:00:00 2001 From: Renaud Thiry Date: Wed, 22 Nov 2023 14:35:26 +0100 Subject: [PATCH] [FIX] mail: consider empty "section" nodes to be empty html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently an empty section is not considered empty text. As the web editor sometimes uses them, it is relevant to consider them when asking whether some html will appear empty. Currently, even completely removing the website description of an exhibitor in website_event_exhibitor from the backend does not make the 'missing description' tooltip appear in the front-end task-3607615 closes odoo/odoo#154097 X-original-commit: 7dc376d4d2d2b4000de0da7573c30e4508f32318 Signed-off-by: Warnon Aurélien (awa) Signed-off-by: Renaud Thiry (reth) --- odoo/addons/base/tests/test_mail.py | 1 + odoo/tools/mail.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/tests/test_mail.py b/odoo/addons/base/tests/test_mail.py index 97d6a3fe39c..ca2a3a3b054 100644 --- a/odoo/addons/base/tests/test_mail.py +++ b/odoo/addons/base/tests/test_mail.py @@ -414,6 +414,7 @@ class TestHtmlTools(BaseCase): self.assertTrue(is_html_empty(content)) void_html_samples = [ + '

', '


', '


', '


', '

', '
', diff --git a/odoo/tools/mail.py b/odoo/tools/mail.py index 19485809702..45b5400c2a1 100644 --- a/odoo/tools/mail.py +++ b/odoo/tools/mail.py @@ -315,7 +315,7 @@ def is_html_empty(html_content): """ if not html_content: return True - tag_re = re.compile(r'\<\s*\/?(?:p|div|span|br|b|i|font)(?:(?=\s+\w*)[^/>]*|\s*)/?\s*\>') + tag_re = re.compile(r'\<\s*\/?(?:p|div|section|span|br|b|i|font)(?:(?=\s+\w*)[^/>]*|\s*)/?\s*\>') return not bool(re.sub(tag_re, '', html_content).strip()) def html_keep_url(text):