#1691·imgproxy

Empty XML comment in SVG panics the minifier (500)

Author: diegoatpitchCreated Jul 13, 2026Updated Jul 13, 2026

Version 4.0.11 Processing any SVG that contains an empty XML comment (<!---->) causes the SVG minifier to panic and return to the client as HTTP 500.

Minimal reproduction

xml
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><!----><rect width="10" height="10"/></svg>

Replacing <!----> with any non-empty body (<!--x-->) renders fine.

Stack trace (from prod logs)

runtime error: index out of range [0] with length 0
/app/processing/svg/minify/minify.go:146  (*minifier).cleanupWalk.func1.(*minifier).cleanupWalk.1
/app/xmlparser/node.go:22                  (*Node).FilterChildren.func1
/usr/local/go/src/slices/slices.go:109     slices.IndexFunc[...]
/usr/local/go/src/slices/slices.go:240     slices.DeleteFunc[...]
/app/xmlparser/node.go:21                  (*Node).FilterChildren
/app/processing/svg/minify/minify.go:138   (*minifier).cleanupWalk.func1
/app/processing/svg/minify/minify.go:168   (*minifier).cleanupWalk.func1