From 71792870872d1907d7bfe4ce022edfc9f246dde1 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Sun, 12 Jul 2026 12:06:07 -0700 Subject: [PATCH] fix(builder): sanitize HtmlBlock/Countdown/Gallery JS contexts Entity-escaping alone doesn't protect JS-string or raw-HTML sinks: - HtmlBlock.toHtml exported props.code raw; now runs it through the same purifyHtml (DOMPurify) config already used for the live editor preview, so

hi

' }, ''); + expect(html).not.toContain('hi

'); + }); +}); diff --git a/craft/src/components/basic/HtmlBlock.tsx b/craft/src/components/basic/HtmlBlock.tsx index b0fd034..a5b05df 100644 --- a/craft/src/components/basic/HtmlBlock.tsx +++ b/craft/src/components/basic/HtmlBlock.tsx @@ -140,6 +140,7 @@ HtmlBlock.craft = { /* ---------- HTML export ---------- */ (HtmlBlock as any).toHtml = (props: HtmlBlockProps, _childrenHtml: string) => { - // Output the raw code as-is - return { html: props.code || '' }; + // Run through the same DOMPurify config used for the live editor preview + // so exported pages can't carry `; } return { html: ` -
+ ${items}
${lightboxHtml} `,