diff --git a/pkg/filesystem/validator.go b/pkg/filesystem/validator.go index 06f4c05..94a735b 100644 --- a/pkg/filesystem/validator.go +++ b/pkg/filesystem/validator.go @@ -4,6 +4,7 @@ import ( "context" "github.com/HFO4/cloudreve/pkg/util" "path/filepath" + "strings" ) // ValidateFileSize 验证上传的文件大小是否超出限制 @@ -26,7 +27,7 @@ func (fs *FileSystem) ValidateExtension(ctx context.Context, fileName string) bo return true } - ext := filepath.Ext(fileName) + ext := strings.ToLower(filepath.Ext(fileName)) // 无扩展名时 if len(ext) == 0 { return false diff --git a/pkg/filesystem/validator_test.go b/pkg/filesystem/validator_test.go index ed28181..6d68f07 100644 --- a/pkg/filesystem/validator_test.go +++ b/pkg/filesystem/validator_test.go @@ -86,5 +86,6 @@ func TestFileSystem_ValidateExtension(t *testing.T) { asserts.False(fs.ValidateExtension(ctx, "1.jpg.png")) asserts.True(fs.ValidateExtension(ctx, "1.txt")) asserts.True(fs.ValidateExtension(ctx, "1.png.jpg")) + asserts.True(fs.ValidateExtension(ctx, "1.png.jpG")) asserts.False(fs.ValidateExtension(ctx, "1.png")) }