Fix content-type detection for small files

Previously a <512 byte file without an extension resulted in:

internal server error: runtime error: slice bounds out of range [:512] with capacity 8
This commit is contained in:
David Leadbeater
2025-11-21 05:55:50 +01:00
committed by Catherine
parent b1b8ae26e8
commit b5a1626a10
+1 -1
View File
@@ -148,7 +148,7 @@ func DetectContentType(manifest *Manifest) {
} else if entry.GetType() == Type_InlineFile && entry.GetTransform() == Transform_None {
contentType := mime.TypeByExtension(filepath.Ext(path))
if contentType == "" {
contentType = http.DetectContentType(entry.Data[:512])
contentType = http.DetectContentType(entry.Data[:min(512, len(entry.Data))])
}
entry.ContentType = proto.String(contentType)
} else {