mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Improve external media removal in style blocks
This commit is contained in:
		@@ -463,6 +463,7 @@ export function encodeStyleTags(text) {
 | 
			
		||||
 */
 | 
			
		||||
export function decodeStyleTags(text) {
 | 
			
		||||
    const styleDecodeRegex = /<custom-style>(.+?)<\/custom-style>/gms;
 | 
			
		||||
    const mediaAllowed = isExternalMediaAllowed();
 | 
			
		||||
 | 
			
		||||
    return text.replaceAll(styleDecodeRegex, (_, style) => {
 | 
			
		||||
        try {
 | 
			
		||||
@@ -491,6 +492,13 @@ export function decodeStyleTags(text) {
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                        if (!mediaAllowed && Array.isArray(rule.declarations) && rule.declarations.length > 0) {
 | 
			
		||||
                            for (const declaration of rule.declarations) {
 | 
			
		||||
                                if (declaration.value.includes('://')) {
 | 
			
		||||
                                    rule.declarations.splice(rule.declarations.indexOf(declaration), 1);
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user