forked from mtusi2026/mtusi2026lab4
исправления
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user