fix(charts): strip ECharts navigation sinks from .chart documents
Merged
WA
2mo ago+51+51+01234567890123456789-4-4-0123456789
Summary
confineOptionToCanvasclosed the ECharts DOM sinks (tooltipinnerHTML,toolboxdataView/saveAsImage) but left the navigation ones open —title.link,title.sublink, and alinkon a treemap or sunburst data item each reachwindowOpen, which assigns the URL tolocation.href- A
.chartdocument is author-controlled and rendered withsetOption()straight into the app document (unsandboxed, unlike the HTML preview alongside it), including on the anonymous/f/<token>share route — so ajavascript:URL in one executed script on the app origin on a single click - Drop
link/sublinkeverywhere in the walk alongsidetoolbox. A chart has no reason to navigate its viewer, so they're stripped rather than scheme-checked, which would still leave an open redirect on an authenticated origin target/subtargetare left alone — all four call sites are guarded on a truthy link, so removing the link is sufficient and avoids collateral on any unrelatedtargetkey
Type of Change
- Bug fix
Testing
apps/sim/lib/charts/spec.test.ts— 23/23 passing; the two new tests were confirmed red against the unpatched sanitizer first- One test pins the sanitizer output (title link/sublink plus treemap and sunburst item links, including under
baseOptionandmedia); the other renders through real echarts and asserts the title component resolves nolink/sublinkto hand towindowOpen bun run lint,bun run check:audits(39/39),check-block-registryall pass
Checklist
- Code follows project style guidelines
- Self-reviewed my changes
- Tests added/updated and passing
- No new warnings introduced
- I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)