From 2c1ab04cc72396f29d938734ce0a86e393ee4552 Mon Sep 17 00:00:00 2001 From: Niclas Overby Date: Fri, 6 Mar 2026 14:25:24 +0100 Subject: [PATCH] appview,knotserver,camo: add AVIF and modern image format support Add support for AVIF, JPEG XL, and HEIF image formats across the stack: - knotserver/xrpc: override MIME types for formats that Go's http.DetectContentType does not recognize (.avif, .jxl, .heic, .heif), using a switch statement like the existing .svg override - camo: add image/avif, image/heif, and image/jxl to the allowed MIME types list - appview/repo: add .avif, .jxl, .heic, .heif to the image extension list in the blob viewer Without these changes, AVIF files (and other modern formats) are rejected by the knot server with a 403 (detected as application/octet-stream), blocked by the camo proxy with a 415, and not previewed in the blob viewer. Signed-off-by: Niclas Overby --- appview/repo/blob.go | 2 +- camo/src/mimetypes.json | 3 +++ knotserver/xrpc/repo_blob.go | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/appview/repo/blob.go b/appview/repo/blob.go index b5f3f3b4..c7fd680c 100644 --- a/appview/repo/blob.go +++ b/appview/repo/blob.go @@ -236,7 +236,7 @@ func NewBlobView(resp *tangled.RepoBlob_Output, config *config.Config, repo *mod ext := strings.ToLower(filepath.Ext(resp.Path)) switch ext { - case ".jpg", ".jpeg", ".png", ".gif", ".webp": + case ".jpg", ".jpeg", ".png", ".gif", ".webp", ".avif", ".jxl", ".heic", ".heif": view.ContentType = models.BlobContentTypeImage view.HasRawView = true view.HasRenderedView = true diff --git a/camo/src/mimetypes.json b/camo/src/mimetypes.json index f9e04653..46f106b5 100644 --- a/camo/src/mimetypes.json +++ b/camo/src/mimetypes.json @@ -1,10 +1,13 @@ [ + "image/avif", "image/bmp", "image/cgm", "image/g3fax", "image/gif", + "image/heif", "image/ief", "image/jp2", + "image/jxl", "image/jpeg", "image/jpg", "image/pict", diff --git a/knotserver/xrpc/repo_blob.go b/knotserver/xrpc/repo_blob.go index c8add0c7..91570348 100644 --- a/knotserver/xrpc/repo_blob.go +++ b/knotserver/xrpc/repo_blob.go @@ -74,8 +74,16 @@ func (x *Xrpc) RepoBlob(w http.ResponseWriter, r *http.Request) { mimeType := http.DetectContentType(contents) - if filepath.Ext(treePath) == ".svg" { + // override MIME types for formats that http.DetectContentType does not recognize + switch filepath.Ext(treePath) { + case ".svg": mimeType = "image/svg+xml" + case ".avif": + mimeType = "image/avif" + case ".jxl": + mimeType = "image/jxl" + case ".heic", ".heif": + mimeType = "image/heif" } if raw { -- 2.51.2