исправления

This commit is contained in:
2026-11-06 17:33:49 +03:00
parent a7d4764c6d
commit ab56a4512d
5 changed files with 58 additions and 29 deletions
+3 -6
View File
@@ -28,7 +28,6 @@ import (
const (
maxAttachmentBytes = 10 << 20
maxPixels = 40_000_000
fullDecodePixels = 4_000_000 // полное декодирование только для небольших изображений
)
func validFilename(s string) bool {
@@ -139,11 +138,9 @@ func (a *api) handleUploadAttachment(w http.ResponseWriter, r *http.Request, u m
writeError(w, http.StatusRequestEntityTooLarge, requestID, codeTooLarge, "image has too many pixels")
return
}
if pixels <= fullDecodePixels {
if _, _, err := image.Decode(io.NewSectionReader(tmp, 0, n)); err != nil {
writeError(w, http.StatusUnsupportedMediaType, requestID, codeUnsupportedMedia, "corrupted image")
return
}
if _, _, err := image.Decode(io.NewSectionReader(tmp, 0, n)); err != nil {
writeError(w, http.StatusUnsupportedMediaType, requestID, codeUnsupportedMedia, "corrupted image")
return
}
id := idgen.GenerateUUIDv4()