mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-08-17 09:26:04 +00:00
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:
committed by
Catherine
parent
b1b8ae26e8
commit
b5a1626a10
+1
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user