Skip to content

magick_cli: identify errors on SVG badges with embedded data URIs escape pcall #370

Description

@valVk

Environment

  • image.nvim: 44e0712 (latest master)
  • Neovim: v0.12.2
  • ImageMagick: 7.1.2-25 CLI (magick_cli processor)
  • librsvg / rsvg-convert: 2.62.3 (installed, configured as ImageMagick SVG delegate)
  • OS: macOS (Apple Silicon, Darwin 25.5.0)

What happens

Opening any markdown file with remote badge images (shields.io, badgen.net, travis-ci) triggers repeated error notifications:

Lua callback:

...image.nvim/lua/image/processors/magick_cli.lua:115: identify: unable to open image
'image/svg+xml;base64,PHN2Gy...': No such file or directory @ error/blob.c/OpenBlob/3690

Root cause

The error is not from image.nvim passing a data URI as a path. The chain is:

  1. Remote badge URL (e.g. badgen.net) is downloaded → temp SVG file
  2. is_image() correctly recognises SVG → get_dimensions(tmp_path) is called
  3. magick identify <tmp_path> runs on the SVG file
  4. The badge SVG contains embedded icons as <image href="data:image/svg+xml;base64,..."/> elements
  5. ImageMagick's internal SVG renderer tries to open image/svg+xml;base64,... as a file path (strips data:, treats the MIME type as a relative path) → fails with non-zero exit
  6. error() fires inside the vim.loop.spawn callback at magick_cli.lua:115 → escapes the surrounding pcall in document.lua → notification shown to user

Reproducible without Neovim:

curl -s "https://badgen.net/badge/Bitcoin/Donate/F19537?icon=bitcoin" -o /tmp/badge.svg
magick identify /tmp/badge.svg

# → identify: unable to open image 'image/svg+xml;base64,...': No such file or directory

Two separate issues

  1. ImageMagick SVG bug - identify doesn't handle data: URIs in SVG <image> elements. Using rsvg-convert (the configured SVG delegate) for SVG dimension extraction would avoid this, as rsvg-convert handles embedded data URIs correctly. Alternatively, parse viewBox/width/height directly from the SVG XML.
  2. image.nvim error handling - error() inside vim.loop.spawn async callback escapes pcall. The non-zero exit from identify should be caught per-file without propagating as a user-visible notification.

Report generated by Claude, but issue is real (

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions