Fix external style declaration filtering
| @@ -466,11 +466,11 @@ export function decodeStyleTags(text) { | |||
| 466 | const mediaAllowed = isExternalMediaAllowed(); | 466 | const mediaAllowed = isExternalMediaAllowed(); |
| 467 | 467 | ||
| 468 | function sanitizeRule(rule) { | 468 | function sanitizeRule(rule) { |
| 469 | if (rule.selectors) { | 469 | if (Array.isArray(rule.selectors)) { |
| 470 | for (let i = 0; i < rule.selectors.length; i++) { | 470 | for (let i = 0; i < rule.selectors.length; i++) { |
| 471 | let selector = rule.selectors[i]; | 471 | const selector = rule.selectors[i]; |
| 472 | if (selector) { | 472 | if (selector) { |
| 473 | let selectors = (selector.split(' ') ?? []).map((v) => { | 473 | const selectors = (selector.split(' ') ?? []).map((v) => { |
| 474 | if (v.startsWith('.')) { | 474 | if (v.startsWith('.')) { |
| 475 | return '.custom-' + v.substring(1); | 475 | return '.custom-' + v.substring(1); |
| 476 | } | 476 | } |
| @@ -482,16 +482,12 @@ export function decodeStyleTags(text) { | |||
| 482 | } | 482 | } |
| 483 | } | 483 | } |
| 484 | if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) { | 484 | 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 | } | ||
| 490 | } | 486 | } |
| 491 | } | 487 | } |
| 492 | 488 | ||
| 493 | function sanitizeRuleSet(ruleSet) { | 489 | function sanitizeRuleSet(ruleSet) { |
| 494 | if (ruleSet.type === 'rule') { | 490 | if (Array.isArray(ruleSet.selectors) || Array.isArray(ruleSet.declarations)) { |
| 495 | sanitizeRule(ruleSet); | 491 | sanitizeRule(ruleSet); |
| 496 | } | 492 | } |
| 497 | 493 | ||