improve dnd; prevent large files early on upload
This commit is contained in:
@@ -53,8 +53,14 @@ func UploadHandler(db *gorm.DB, cfg config.Config, p *pages.Pages) http.HandlerF
|
||||
return
|
||||
}
|
||||
|
||||
maxUploadSize := max(cfg.MaxFileBytes, cfg.MaxPasteBytes)
|
||||
if r.ContentLength > maxUploadSize {
|
||||
p.HTTPError(w, r, "upload too large", http.StatusRequestEntityTooLarge)
|
||||
return
|
||||
}
|
||||
|
||||
// use the largest of the sizes, and then do another size check per type down the line
|
||||
r.Body = http.MaxBytesReader(w, r.Body, max(cfg.MaxFileBytes, cfg.MaxPasteBytes))
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxUploadSize)
|
||||
|
||||
var err error
|
||||
mediaType := "text/plain"
|
||||
|
||||
Reference in New Issue
Block a user