v0.0.493 fix panic in RegisterImage for very short images
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 5m22s

This commit is contained in:
2024-08-07 09:22:37 +02:00
parent ffffe4bf24
commit f1b4480e0f
4 changed files with 35 additions and 12 deletions

View File

@@ -65,7 +65,12 @@ func (b *WPDFBuilder) RegisterImage(bin []byte, opts ...*PDFImageRegisterOpt) *P
}
if imageType == "" {
ct := http.DetectContentType(bin[:512])
ct := ""
if len(bin) > 512 {
ct = http.DetectContentType(bin[:512])
} else {
ct = http.DetectContentType(bin)
}
switch ct {
case "image/jpg":
imageType = "JPG"