فهرست منبع

Merge branch 'security_fix/uploadfile_ix' into debug

kobe6258 3 ماه پیش
والد
کامیت
e0b7063243
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 3 1
      utils/file.go

+ 3 - 1
utils/file.go

@@ -4,6 +4,7 @@ import (
 	"fmt"
 	"github.com/h2non/filetype"
 	"github.com/h2non/filetype/types"
+	"strings"
 	"sync"
 )
 
@@ -54,9 +55,10 @@ func CheckFileType(buf []byte, sourceType SourceType, exactFileType []string, fi
 	}
 }
 func exactFile(exactFileType []string, fileKind types.Type, fileExt string) bool {
+	lowCase := strings.ToLower(fileExt)
 	for _, fileType := range exactFileType {
 		if fileKind.Extension == fileType {
-			if fileExt != "" && (fileExt == fmt.Sprintf(".%s", fileKind.Extension) || (fileExt == ".jpeg" && fileKind.Extension == "jpg")) {
+			if lowCase != "" && (lowCase == fmt.Sprintf(".%s", fileKind.Extension) || (lowCase == ".jpeg" && fileKind.Extension == "jpg")) {
 				return true
 			}
 			return false