Spaces:
Runtime error
Runtime error
Adrien Denat Eliott C. commited on
add basic html sanitizing (#40)
Browse files* add basic html sanitizing
* fix prose overriding styling of code block
* lazy load HTML sanitizer
* simplify sanitization
* make sure sanitizedContent is kicking in on prop changes
Co-authored-by: Eliott C. <coyotte508@gmail.com>
* fix reactive statement not running on SSR
---------
Co-authored-by: Eliott C. <coyotte508@gmail.com>
Files changed (2)
5 unmodified lines6789101137 unmodified lines49505152535455565725 unmodified lines838485868788895 unmodified linesimport CopyToClipBoardBtn from '../CopyToClipBoardBtn.svelte';export let message: Message;let html = '';let el: HTMLElement;37 unmodified linesrenderer};$: browser && marked(message.content, options, handleParsed);html = marked(message.content, options);afterUpdate(() => {if (el) {25 unmodified linesclass="mt-5 w-3 h-3 flex-none rounded-full shadow-lg"/><divclass="relative rounded-2xl px-5 py-3.5 border border-gray-100 bg-gradient-to-br from-gray-50 dark:from-gray-800/40 dark:border-gray-800 prose text-gray-600 dark:text-gray-300"bind:this={el}>{@html html}5 unmodified lines678910111213141537 unmodified lines53545556575859606125 unmodified lines878889909192935 unmodified linesimport CopyToClipBoardBtn from '../CopyToClipBoardBtn.svelte';function sanitizeMd(md: string) {return md.replaceAll('<', '<');}export let message: Message;let html = '';let el: HTMLElement;37 unmodified linesrenderer};$: browser && marked(sanitizeMd(message.content), options, handleParsed);html = marked(sanitizeMd(message.content), options);afterUpdate(() => {if (el) {25 unmodified linesclass="mt-5 w-3 h-3 flex-none rounded-full shadow-lg"/><divclass="prose dark:prose-invert :prose-pre:bg-gray-100 dark:prose-pre:bg-gray-950 relative rounded-2xl px-5 py-3.5 border border-gray-100 bg-gradient-to-br from-gray-50 dark:from-gray-800/40 dark:border-gray-800 text-gray-600 dark:text-gray-300"bind:this={el}>{@html html}
15 unmodified lines1617181920212215 unmodified lines}.code-block {@apply relative bg-gray-100 dark:bg-gray-950 rounded-lg my-4;}.code-block > pre {15 unmodified lines1617181920212215 unmodified lines}.code-block {@apply relative rounded-lg my-4;}.code-block > pre {
src/lib/components/chat/ChatMessage.svelte+7-3
src/styles/main.css+1-1