Improve external media removal in style blocks

99e09f0b91fc918b547f63f0a88f6f7289d8d898

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +8 -0Showing whitespace changes
public/scripts/chats.js+8 -0
@@ -463,6 +463,7 @@ export function encodeStyleTags(text) {
463463 */
464464export function decodeStyleTags(text) {
465465 const styleDecodeRegex = /<custom-style>(.+?)<\/custom-style>/gms;
466+ const mediaAllowed = isExternalMediaAllowed();
466467
467468 return text.replaceAll(styleDecodeRegex, (_, style) => {
468469 try {
@@ -491,6 +492,13 @@ export function decodeStyleTags(text) {
491492 }
492493 }
493494 }
495+ if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) {
496+ for (const declaration of rule.declarations) {
497+ if (declaration.value.includes('://')) {
498+ rule.declarations.splice(rule.declarations.indexOf(declaration), 1);
499+ }
500+ }
501+ }
494502 }
495503 }
496504 }