Fix external style declaration filtering

66db820c9e6a66300499ca3fe46c934b7f9d4f8e

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

1 files changed, +5 -9Ignore whitespace
public/scripts/chats.js+5 -9
@@ -466,11 +466,11 @@ export function decodeStyleTags(text) {
466466 const mediaAllowed = isExternalMediaAllowed();
467467
468468 function sanitizeRule(rule) {
469469 if (Array.isArray(rule.selectors)) {
470470 for (let i = 0; i < rule.selectors.length; i++) {
471471 letconst selector = rule.selectors[i];
472472 if (selector) {
473473 letconst selectors = (selector.split(' ') ?? []).map((v) => {
474474 if (v.startsWith('.')) {
475475 return '.custom-' + v.substring(1);
476476 }
@@ -482,16 +482,12 @@ export function decodeStyleTags(text) {
482482 }
483483 }
484484 if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) {
485- for (const declaration of rule.declarations) {
485+ rule.declarations = rule.declarations.filter(declaration => !declaration.value.includes('://'));
486- if (declaration.value.includes('://')) {
487- rule.declarations.splice(rule.declarations.indexOf(declaration), 1);
488- }
489- }
490486 }
491487 }
492488
493489 function sanitizeRuleSet(ruleSet) {
494- if (ruleSet.type === 'rule') {
490+ if (Array.isArray(ruleSet.selectors) || Array.isArray(ruleSet.declarations)) {
495491 sanitizeRule(ruleSet);
496492 }
497493