feat: added SVG file preview to the editor file view#1492
Open
MarkQuach12 wants to merge 6 commits into
Open
Conversation
Contributor
|
Hey @MarkQuach12 thanks for your contribution. We tried the same solution, but we reverted (hopefully only temporary) due to security concerns. You can see the revert commit in ad651a2. An extra sanitisation layer (like |
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.
Description
Adds a preview for SVG files in the editor file view. Previously, selecting an
.svgfile in the file tree showed "No preview available"; it now renders the image, matching the behaviour of PNG/JPG/GIF files.The blob endpoint serves every file as
application/octet-stream, and browsers deliberately refuse to content-sniff SVG (an anti-XSS measure), so a direct<img src>to the blob renders blank. Instead, a newFileViewSvgcomponent fetches the blob and re-wraps the bytes as animage/svg+xmlobject URL, which renders reliably with no backend change. Rendering through an<img>also means any scripts embedded in the SVG never execute, so no new XSS surface is introduced.Related issues / Pull Requests
Related to #1458
Contributor Agreement
(Feedback appreciated, my first open source pr :))