From 36282393fdb6218b96da388bb022d8832e6bc899 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Fri, 21 Feb 2025 08:42:46 -0800 Subject: [PATCH] imagebundler: treat octet streams with svg signature as svg mimetypes --- lib/imgbundler/imgbundler.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/imgbundler/imgbundler.go b/lib/imgbundler/imgbundler.go index 2c3bce289..7dbd6268e 100644 --- a/lib/imgbundler/imgbundler.go +++ b/lib/imgbundler/imgbundler.go @@ -166,7 +166,7 @@ func worker(ctx context.Context, l simplelog.Logger, inputPath string, href []by var err error if isRemote { l.Debug(fmt.Sprintf("fetching %s remotely", string(href))) - buf, mimeType, err = httpGet(ctx, html.UnescapeString(string(href))) + buf, mimeType, err = httpGet(ctx, l, html.UnescapeString(string(href))) } else { l.Debug(fmt.Sprintf("reading %s from disk", string(href))) path := html.UnescapeString(string(href)) @@ -181,8 +181,15 @@ func worker(ctx context.Context, l simplelog.Logger, inputPath string, href []by if mimeType == "" { mimeType = sniffMimeType(href, buf, isRemote) + l.Debug(fmt.Sprintf("no mimetype provided - sniffed MIME type for %s: %s", string(href), mimeType)) + } else { + l.Debug(fmt.Sprintf("mimetype provided for %s: %s", string(href), mimeType)) } mimeType = strings.Replace(mimeType, "text/xml", "image/svg+xml", 1) + if mimeType == "application/octet-stream" && bytes.Contains(buf, []byte("