mermaid: allow data URI images in chat/preview CSP#317235
Merged
Merged
Conversation
Co-authored-by: mjbvz <12821956+mjbvz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix mermaid image rendering issue in context diagram
mermaid: allow data URI images in chat/preview CSP
May 19, 2026
mjbvz
approved these changes
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes missing icons in Mermaid C4 diagrams rendered in chat (and aligns editor preview behavior) by allowing data: image sources in the webview Content Security Policy, while keeping the overall CSP restrictive (default-src 'none').
Changes:
- Add
img-src data:to the Mermaid chat output renderer webview CSP. - Add
img-src data:to the Mermaid editor preview webview CSP.
Show a summary per file
| File | Description |
|---|---|
| extensions/mermaid-markdown-features/src/editorManager.ts | Allows data: images in the editor preview webview CSP so Mermaid-emitted data URI icons can render. |
| extensions/mermaid-markdown-features/src/chatOutputRenderer.ts | Allows data: images in the chat renderer webview CSP to fix missing C4/person icons in chat output. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
benvillalobos
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mermaid C4 diagrams in chat could render with missing icons (for example, the person icon in the attached repro) because image data URIs were blocked by the webview CSP fallback to
default-src 'none'. Markdown preview worked because it already allows image sources explicitly.What changed
img-src data:directive to Mermaid webview CSP in:extensions/mermaid-markdown-features/src/chatOutputRenderer.tsextensions/mermaid-markdown-features/src/editorManager.tsSecurity posture
default-src 'none'and existing script/style/font restrictions unchanged.data:images emitted by Mermaid rendering.