From 5aedc3a4f66db9b8c776d9a388be35014aa7ba47 Mon Sep 17 00:00:00 2001 From: Kailash Nadh Date: Sat, 25 Mar 2023 11:46:05 +0530 Subject: [PATCH] Make media upload file extension validation case insensitive. Closes #1256. --- cmd/media.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/media.go b/cmd/media.go index 0a3cc74..13a03f8 100644 --- a/cmd/media.go +++ b/cmd/media.go @@ -6,6 +6,7 @@ import ( "net/http" "path/filepath" "strconv" + "strings" "github.com/disintegration/imaging" "github.com/knadh/listmonk/models" @@ -39,7 +40,7 @@ func handleUploadMedia(c echo.Context) error { } // Validate file extension. - ext := filepath.Ext(file.Filename) + ext := strings.ToLower(filepath.Ext(file.Filename)) if ok := inArray(ext, validExts); !ok { return echo.NewHTTPError(http.StatusBadRequest, app.i18n.Ts("media.unsupportedFileType", "type", ext))