[FIX] mail, mass_mailing: fix picture of masanry snippet in mailing test

- Go to Email Marketing and create a new mailing
- Add Masonry snippet in mail body
- Send a test mail
The picture of the Masonry snippet is missing.

The masonry image is displayed with CSS via background-image attribute.

There are 2 causes for this issue:

1) The relative url cannot be converted to an absolute one.
This is due to the " entity used to surround the url that is not detected.

style="background-image: url("/web/image/mass_mailing.s_masonry_block_default_image_1");"

2) html_sanitize is applied to mail body, but html_sanitize doesn't allow
background-image style attribute.

opw-2735636

closes odoo/odoo#83998

X-original-commit: cdcef228aa30d7dd4081fa25a1aab4811acda3ad
Signed-off-by: Antoine Guenet <age@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2022-02-04 16:54:09 +00:00
parent 45631cfcea
commit 440be3f9e2
2 changed files with 1 additions and 2 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ class MailRenderMixin(models.AbstractModel):
r"""( # Group 1: element up to url in style
<[^>]+\bstyle=" # Element with a style attribute
[^"]+\burl\( # Style attribute contains "url(" style
(?:&\#34;|')?) # url style may start with (escaped) quote: capture it
(?:&\#34;|'|&quot;)?) # url style may start with (escaped) quote: capture it
( # Group 2: url itself
/(?:[^'")]|(?!&\#34;))+ # stop at the first closing quote
)""", re.VERBOSE), _sub_relative2absolute, html)
@@ -49,7 +49,6 @@ class TestMassMailing(models.TransientModel):
# Convert links in absolute URLs before the application of the shortener
full_body = self.env['mail.render.mixin']._replace_local_links(full_body)
full_body = tools.html_sanitize(full_body, sanitize_attributes=True, sanitize_style=True)
for valid_email in valid_emails:
mail_values = {