fix: sanitize a large svg result before showing it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Guilhem Lemouel
2026-11-25 08:46:12 -08:00
co-authored by Claude Opus 5.5
parent 3f94112d2d
commit 2aff78ecdd
@@ -364,10 +364,13 @@
>[0]
)
if (!field) throw new Error(`the result has no ${image.kind} content`)
// Drawn by an <img>, 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) {