From ec30c9767a55094ca6ab4a56f432200339f172a0 Mon Sep 17 00:00:00 2001 From: Kuuuube <61125188+Kuuuube@users.noreply.github.com> Date: Tue, 31 Dec 2024 19:27:42 -0500 Subject: [PATCH] Make sanitizer fail entirely on any errors (#1725) --- ext/js/core/utilities.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/ext/js/core/utilities.js b/ext/js/core/utilities.js index 416697235..7a0040182 100644 --- a/ext/js/core/utilities.js +++ b/ext/js/core/utilities.js @@ -16,8 +16,6 @@ * along with this program. If not, see . */ -import {log} from './log.js'; - /** * Converts any string into a form that can be passed into the RegExp constructor. @@ -271,15 +269,7 @@ export function promiseTimeout(delay) { * @returns {string} */ export function sanitizeCSS(css) { - let sanitizer; - // As of 2023/03/xx, all latest browser versions support this but some forks may lag behind - try { - sanitizer = new CSSStyleSheet(); - } catch (e) { - log.log('Failed to sanitize dictionary styles'); - log.warn(e); - return css; - } + const sanitizer = new CSSStyleSheet(); sanitizer.replaceSync(css); return [...sanitizer.cssRules].map((rule) => rule.cssText || '').join('\n'); }