Improve external media removal in style blocks

99e09f0b91fc918b547f63f0a88f6f7289d8d898

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

1 files changed, +8 -0Ignore whitespace
public/scripts/chats.js+8 -0
@@ -463,6 +463,7 @@ export function encodeStyleTags(text) {
463 */463 */
464export function decodeStyleTags(text) {464export function decodeStyleTags(text) {
465 const styleDecodeRegex = /<custom-style>(.+?)<\/custom-style>/gms;465 const styleDecodeRegex = /<custom-style>(.+?)<\/custom-style>/gms;
466 const mediaAllowed = isExternalMediaAllowed();
466467
467 return text.replaceAll(styleDecodeRegex, (_, style) => {468 return text.replaceAll(styleDecodeRegex, (_, style) => {
468 try {469 try {
@@ -491,6 +492,13 @@ export function decodeStyleTags(text) {
491 }492 }
492 }493 }
493 }494 }
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 }
494 }502 }
495 }503 }
496 }504 }