/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const LUMINANCE_THRESHOLD = 200; const CONTRAST_THRESHOLD = 3.5; /** * Bug 1967725 - Sanitize color-related styles from quoted content in * reply/forward compose windows to prevent the original message's colors * from bleeding into the compose area, and adapt quoted content for dark * mode to match the reader pane appearance. */ export var QuoteSanitizer = { /** * Sanitize quoted content styles in a compose document. * * @param {Document} doc - The compose editor document. * @param {boolean} isDarkMode - Whether dark mode is active. */ sanitize(doc, isDarkMode) { const { body } = doc; // Phase 1: Strip body-level color attributes and styles. When // forwarding inline, the original message's
attributes are copied onto the compose document's body, // suppressing the user's own color preferences. for (const attr of [ "bgcolor", "text", "background", "link", "vlink", "alink", ]) { body.removeAttribute(attr); } body.style.removeProperty("background-color"); body.style.removeProperty("background"); body.style.removeProperty("color"); // Phase 2: Scope