From 5ea4baa6129a576ce82ded8bdbfdf69c8b278c93 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 10 Jul 2023 10:16:59 +0000 Subject: [PATCH] [FIX] web_editor: prevent double quotes in font-family style The `font-family` style can sometimes include double quotes. This isn't really a problem since these get escaped (`"`) but emailonacid currently has a bug where the double quotes cause every subsequent style to be ignored, and the rendering to be incorrect. For the sake of future testing, this converts them to single quotes. It also removes the style entirely from image elements since they don't make sense there. X-original-commit: 03c7e69db63f326c7a3b3085debc5d3a5c95966d Part-of: odoo/odoo#129153 --- addons/web_editor/static/src/js/backend/convert_inline.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index 670d72083ea..f501e7fc0c7 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -756,6 +756,14 @@ async function toInline($editable, cssRules, $iframe) { // Hide replaced cells on Outlook editable.querySelectorAll('.mso-hide').forEach(_hideForOutlook); + // Replace double quotes in font-family styles with simple quotes (and + // simply remove these styles from images). + editable.querySelectorAll('[style*=font-family]').forEach(n => ( + n.nodeName === 'IMG' + ? n.style.removeProperty('font-family') + : n.setAttribute('style', n.getAttribute('style').replaceAll('"', '\'')) + )); + // Styles were applied inline, we don't need a style element anymore. $editable.find('style').remove();