mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-15 11:40:44 +01:00
Fix external style declaration filtering
This commit is contained in:
parent
62a1919402
commit
66db820c9e
@ -466,11 +466,11 @@ export function decodeStyleTags(text) {
|
|||||||
const mediaAllowed = isExternalMediaAllowed();
|
const mediaAllowed = isExternalMediaAllowed();
|
||||||
|
|
||||||
function sanitizeRule(rule) {
|
function sanitizeRule(rule) {
|
||||||
if (rule.selectors) {
|
if (Array.isArray(rule.selectors)) {
|
||||||
for (let i = 0; i < rule.selectors.length; i++) {
|
for (let i = 0; i < rule.selectors.length; i++) {
|
||||||
let selector = rule.selectors[i];
|
const selector = rule.selectors[i];
|
||||||
if (selector) {
|
if (selector) {
|
||||||
let selectors = (selector.split(' ') ?? []).map((v) => {
|
const selectors = (selector.split(' ') ?? []).map((v) => {
|
||||||
if (v.startsWith('.')) {
|
if (v.startsWith('.')) {
|
||||||
return '.custom-' + v.substring(1);
|
return '.custom-' + v.substring(1);
|
||||||
}
|
}
|
||||||
@ -482,16 +482,12 @@ export function decodeStyleTags(text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) {
|
if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) {
|
||||||
for (const declaration of rule.declarations) {
|
rule.declarations = rule.declarations.filter(declaration => !declaration.value.includes('://'));
|
||||||
if (declaration.value.includes('://')) {
|
|
||||||
rule.declarations.splice(rule.declarations.indexOf(declaration), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeRuleSet(ruleSet) {
|
function sanitizeRuleSet(ruleSet) {
|
||||||
if (ruleSet.type === 'rule') {
|
if (Array.isArray(ruleSet.selectors) || Array.isArray(ruleSet.declarations)) {
|
||||||
sanitizeRule(ruleSet);
|
sanitizeRule(ruleSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user