From 99e09f0b91fc918b547f63f0a88f6f7289d8d898 Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Mon, 27 May 2024 13:43:59 +0300 Subject: [PATCH] Improve external media removal in style blocks --- public/scripts/chats.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/scripts/chats.js b/public/scripts/chats.js index 4bea9ed58..84f316e63 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -463,6 +463,7 @@ export function encodeStyleTags(text) { */ export function decodeStyleTags(text) { const styleDecodeRegex = /(.+?)<\/custom-style>/gms; + const mediaAllowed = isExternalMediaAllowed(); return text.replaceAll(styleDecodeRegex, (_, style) => { try { @@ -491,6 +492,13 @@ export function decodeStyleTags(text) { } } } + if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) { + for (const declaration of rule.declarations) { + if (declaration.value.includes('://')) { + rule.declarations.splice(rule.declarations.indexOf(declaration), 1); + } + } + } } } }