char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
e21152dc9
char/aliceai-t5-moe
1import { SVG } from '$lib/constants' ; 2import DOMPurify from 'dompurify' ; 3 4/** 5* Sanitizes a raw svg string for safe inline rendering. 6* Returns the cleaned svg markup, or an empty string when the input is not a 7* usable svg, exceeds the size ceiling, or sanitizes to nothing. An empty 8* return tells the caller to keep the raw code block instead of rendering. 9*/ 10export function sanitizeSvg ( source :string ) :string { 11const trimmed = source . trim (); 12 13if ( ! trimmed || trimmed . length > SVG . MAX_BYTES ) return '' ; 14 15if ( ! trimmed . startsWith ( SVG . TAG_PREFIX )) return '' ; 16 17const clean = DOMPurify . sanitize ( trimmed , SVG . SANITIZE_CONFIG ) as unknown as string ; 18 19if ( ! clean || ! clean . includes ( SVG . TAG_PREFIX )) return '' ; 20 21return clean ; 22}