[FIX] mail: consider empty "section" nodes to be empty html

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) <awa@odoo.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
This commit is contained in:
Renaud Thiry
2024-02-15 07:54:50 +00:00
parent 73db0b49da
commit ffda905ba7
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -414,6 +414,7 @@ class TestHtmlTools(BaseCase):
self.assertTrue(is_html_empty(content)) self.assertTrue(is_html_empty(content))
void_html_samples = [ void_html_samples = [
'<section><br /> <b><i/></b></section>',
'<p><br></p>', '<p><br> </p>', '<p><br /></p >', '<p><br></p>', '<p><br> </p>', '<p><br /></p >',
'<p style="margin: 4px"></p>', '<p style="margin: 4px"></p>',
'<div style="margin: 4px"></div>', '<div style="margin: 4px"></div>',
+1 -1
View File
@@ -315,7 +315,7 @@ def is_html_empty(html_content):
""" """
if not html_content: if not html_content:
return True 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()) return not bool(re.sub(tag_re, '', html_content).strip())
def html_keep_url(text): def html_keep_url(text):