Skip to content

fix(message): render received external SVG images#13142

Open
joeldj-nl wants to merge 1 commit into
nextcloud:mainfrom
joeldj-nl:fix/render-received-svg-images
Open

fix(message): render received external SVG images#13142
joeldj-nl wants to merge 1 commit into
nextcloud:mainfrom
joeldj-nl:fix/render-received-svg-images

Conversation

@joeldj-nl

Copy link
Copy Markdown

Summary

Received emails containing external SVG images did not render. The message showed only the broken-image placeholder and the image's alt text or name. External images are fetched through the image proxy, which served every response as application/octet-stream. Browsers happily sniff raster formats (PNG/JPEG/GIF) out of an tag regardless of content type, but they refuse to render SVG unless it is served as image/svg+xml, so SVG logos and graphics stayed blank.

Changes

  • Detect SVG markup in proxied responses and serve it with the image/svg+xml content type so browsers render it.
  • Add an SvgSanitizer service that strips active content (scripts, event handlers, external/javascript: references) and rejects DOCTYPE/entity declarations, as defence in depth against XXE and stored XSS even though the context does not execute scripts.

The first screenshot shows the issue; the second screenshot shows it has been resolved.

svg-not-rendering svg-rendering-succeeded

Assisted-by: Claude:claude-opus-4-8

External images are fetched through the image proxy and served with a
generic application/octet-stream content type. Browsers sniff raster
formats in <img> tags, but they refuse to render SVG unless it is served
as image/svg+xml, so SVG logos stayed blank and only the alt text and
placeholder were shown.

Detect SVG markup in the proxied response and serve it as a sanitised
image/svg+xml document. A new SvgSanitizer service strips active content
(scripts, event handlers, external/javascript references) and rejects
DOCTYPE/entity declarations as XXE defence in depth, even though the
<img> context does not execute scripts.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Joël de Jager <contact@joeldejager.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant