Ревью

This commit is contained in:
2026-11-13 10:34:18 +03:00
parent e138dfb13d
commit 048ecd6196
6 changed files with 499 additions and 46 deletions
+7
View File
@@ -417,6 +417,13 @@ func (s *Server) uploadAttachment(w http.ResponseWriter, r *http.Request) {
apperr.Write(w, id, apperr.PayloadTooLarge("image exceeds 40 megapixels"))
return
}
// LAB 5 (ревью): целостность файла проверяется ДО приёма задания.
// DecodeConfig читает только заголовок, поэтому усечённый PNG иначе
// ушёл бы в очередь и упал уже в worker. Ресурсные лимиты сохранены.
if ierr := validateImageIntegrity(data, contentType, width, height); ierr != nil {
apperr.Write(w, id, apperr.UnsupportedMedia("file is corrupted or truncated"))
return
}
attID := uuid.NewString()
stagingKey := store.StagingKey(chat.ID, attID)