From fd61cd29905fedc91ce2f87b5c317ea3f3205300 Mon Sep 17 00:00:00 2001 From: jreakin Date: Mon, 23 Mar 2026 10:01:55 -0500 Subject: [PATCH] fix(web): allow foreignObject in DOMPurify SVG, remove leftover loop code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add ADD_TAGS: ['foreignObject'] to all DOMPurify.sanitize calls — Mermaid uses foreignObject for HTML text labels inside flowchart nodes. The SVG profile was stripping them, causing empty boxes. - Remove leftover sub-batch loop lines from prepared statement hoist Co-Authored-By: Claude Opus 4.6 (1M context) --- gitnexus-web/src/components/MermaidDiagram.tsx | 2 +- gitnexus-web/src/core/lbug/lbug-adapter.ts | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/gitnexus-web/src/components/MermaidDiagram.tsx b/gitnexus-web/src/components/MermaidDiagram.tsx index 447dfe3e7..7b50eafbc 100644 --- a/gitnexus-web/src/components/MermaidDiagram.tsx +++ b/gitnexus-web/src/components/MermaidDiagram.tsx @@ -71,7 +71,7 @@ export const MermaidDiagram = ({ code }: MermaidDiagramProps) => { // Render the diagram const { svg: renderedSvg } = await mermaid.render(id, code.trim()); - const sanitizedSvg = DOMPurify.sanitize(renderedSvg, { USE_PROFILES: { svg: true, svgFilters: true } }); + const sanitizedSvg = DOMPurify.sanitize(renderedSvg, { USE_PROFILES: { svg: true, svgFilters: true }, ADD_TAGS: ['foreignObject'] }); setSvg(sanitizedSvg); setError(null); } catch (err) { diff --git a/gitnexus-web/src/core/lbug/lbug-adapter.ts b/gitnexus-web/src/core/lbug/lbug-adapter.ts index 44551359f..8bd6dc2ba 100644 --- a/gitnexus-web/src/core/lbug/lbug-adapter.ts +++ b/gitnexus-web/src/core/lbug/lbug-adapter.ts @@ -267,12 +267,6 @@ export const loadGraphToLbug = async ( } finally { await stmt.close(); } - - // Yield to event loop between sub-batches - if (i + SUB_BATCH_SIZE < rels.length) { - await new Promise(r => setTimeout(r, 0)); - } - } } if (import.meta.env.DEV) {