Monorepo for Tangled

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 <niclas@overby.me>

authored by overby.me and committed by tangled.org 2c1ab04c 4fb9e0a1

+13 -2
+1 -1
appview/repo/blob.go
··· 236 236 ext := strings.ToLower(filepath.Ext(resp.Path)) 237 237 238 238 switch ext { 239 - case ".jpg", ".jpeg", ".png", ".gif", ".webp": 239 + case ".jpg", ".jpeg", ".png", ".gif", ".webp", ".avif", ".jxl", ".heic", ".heif": 240 240 view.ContentType = models.BlobContentTypeImage 241 241 view.HasRawView = true 242 242 view.HasRenderedView = true
+3
camo/src/mimetypes.json
··· 1 1 [ 2 + "image/avif", 2 3 "image/bmp", 3 4 "image/cgm", 4 5 "image/g3fax", 5 6 "image/gif", 7 + "image/heif", 6 8 "image/ief", 7 9 "image/jp2", 10 + "image/jxl", 8 11 "image/jpeg", 9 12 "image/jpg", 10 13 "image/pict",
+9 -1
knotserver/xrpc/repo_blob.go
··· 74 74 75 75 mimeType := http.DetectContentType(contents) 76 76 77 - if filepath.Ext(treePath) == ".svg" { 77 + // override MIME types for formats that http.DetectContentType does not recognize 78 + switch filepath.Ext(treePath) { 79 + case ".svg": 78 80 mimeType = "image/svg+xml" 81 + case ".avif": 82 + mimeType = "image/avif" 83 + case ".jxl": 84 + mimeType = "image/jxl" 85 + case ".heic", ".heif": 86 + mimeType = "image/heif" 79 87 } 80 88 81 89 if raw {