diff --git a/src/ts/parser.svelte.ts b/src/ts/parser.svelte.ts index abcc6fcb..82ec755e 100644 --- a/src/ts/parser.svelte.ts +++ b/src/ts/parser.svelte.ts @@ -74,6 +74,11 @@ DOMPurify.addHook("uponSanitizeAttribute", (node, data) => { } }) +DOMPurify.addHook('uponSanitizeAttribute', (node, data) => { + if (['IMG', 'SOURCE', 'STYLE'].includes(node.nodeName) && data.attrName === 'src' && data.attrValue.startsWith('asset://localhost/')) { + data.forceKeepAttr = true; + } +}); function renderMarkdown(md:markdownit, data:string){ let quotes = ['“', '”', '‘', '’'] @@ -2278,4 +2283,4 @@ export function parseChatML(data:string):OpenAIChat[]|null{ content: v } }) -} \ No newline at end of file +}