`/sidebar/file` served `.svg` as `image/svg+xml` with no `Content-Disposition`,
no `X-Content-Type-Options` and no CSP. An SVG is a scriptable DOCUMENT, so
navigating to that URL directly (a link, `window.open`, a popup opened by a
previewed page) executes its `<script>` in the GUI's origin — which has
same-origin access to `/sidebar/api/*`, the exact surface the request-trust
fence is there to keep a browsed page away from.
The sibling `/sidebar/html` route already defends this (its own comment calls
the sandbox directive "the previewer's security boundary even for top-level
loads"); the media route simply never got the same treatment, because most of
what it serves is inert.
Fix: mirror the html route for the scriptable type only. When the resolved
media type is `image/svg+xml`, add
content-security-policy: sandbox; object-src 'none'
x-content-type-options: nosniff
referrer-policy: no-referrer
Scope note: `<img src>` embedding is unaffected — CSP applies to the document,
not to an image reference — so the editor's image preview (viewers.tsx renders
`<img>`) and markdown image rewriting keep working unchanged. The guard is
type-scoped, so PNG/JPEG/PDF responses are byte-identical to before.
Verified:
- `smoke.spec.ts` drives the real `/sidebar/file` route: the new case asserts
200 + `image/svg+xml` + a `sandbox` CSP + `nosniff`, and is RED on the
pre-change source (the CSP header is absent). A companion case pins that a
PNG response gains no CSP, so the change cannot silently widen.
- the test helper now surfaces response headers (`invokeGetFull`), reusing the
existing `invokeGet` for every other caller.
- typecheck / lint / build clean.