From 2aff78ecdddbfabecd495033685eb30d1a92d872 Mon Sep 17 00:00:00 2001 From: Guilhem Lemouel Date: Wed, 25 Nov 2026 08:46:12 -0800 Subject: [PATCH] fix: sanitize a large svg result before showing it Co-Authored-By: Claude Opus 5.5 --- frontend/src/lib/components/DisplayResult.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/DisplayResult.svelte b/frontend/src/lib/components/DisplayResult.svelte index dffa465a13..708c23cef9 100644 --- a/frontend/src/lib/components/DisplayResult.svelte +++ b/frontend/src/lib/components/DisplayResult.svelte @@ -364,10 +364,13 @@ >[0] ) if (!field) throw new Error(`the result has no ${image.kind} content`) - // Drawn by an , which runs no script an SVG carries. + // Sanitized whatever `markupTrust` says: the image viewer's "Open in new tab" + // loads the data as a document on Windmill's origin, where an SVG's scripts run. const src = image.kind === 'svg' - ? `data:image/svg+xml;charset=utf-8,${encodeURIComponent(field)}` + ? `data:image/svg+xml;charset=utf-8,${encodeURIComponent( + DOMPurify.sanitize(field, { USE_PROFILES: { svg: true, svgFilters: true } }) + )}` : `data:image/${image.kind};base64,${field}` shownTooBigImage = { apiPath: image.apiPath, src } } catch (e) {