fix(api): fix for incorrect error handling of favicon uploads

This commit is contained in:
Gabe Kangas
2026-03-27 15:34:09 -07:00
parent d9a424ea79
commit 77c7c08587
+7 -1
View File
@@ -2,6 +2,7 @@ package admin
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"net" "net"
@@ -292,7 +293,12 @@ func SetFavicon(w http.ResponseWriter, r *http.Request) {
// Limit request body and parse multipart form with 200KB max // Limit request body and parse multipart form with 200KB max
r.Body = http.MaxBytesReader(w, r.Body, 200<<10) r.Body = http.MaxBytesReader(w, r.Body, 200<<10)
if err := r.ParseMultipartForm(200 << 10); err != nil { if err := r.ParseMultipartForm(200 << 10); err != nil {
webutils.WriteSimpleResponse(w, false, "no file provided") var maxBytesErr *http.MaxBytesError
if errors.As(err, &maxBytesErr) {
webutils.WriteSimpleResponse(w, false, "file too large, max 200KB")
} else {
webutils.WriteSimpleResponse(w, false, "no file provided")
}
return return
} }