diff --git a/LICENSE b/LICENSE index 66402cde..261eeb9e 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 joyqi + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 1fc51e35..3708ce5c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Answer provides a plugin system for developers to create custom plugins and expa We value your feedback and suggestions to improve our documentation. If you have any comments or questions, please feel free to contact us. We’re excited to see what you can create using our plugin system! -You can also check out the [officially supported plugins here](https://github.com/answerdev/plugins). +You can also check out the [plugins here](https://github.com/answerdev/plugins). ## Contributing diff --git a/pkg/checker/file_type.go b/pkg/checker/file_type.go index 37dfdc42..71f9f2a5 100644 --- a/pkg/checker/file_type.go +++ b/pkg/checker/file_type.go @@ -1,21 +1,22 @@ package checker import ( - "image/jpeg" - "image/png" + "image" + _ "image/gif" // use init to support decode jpeg,jpg,png,gif + _ "image/jpeg" + _ "image/png" "io" "strings" ) -// IsSupportedImageFile currently answers support image type is `image/jpeg,image/jpg,image/png` +// IsSupportedImageFile currently answers support image type is `image/jpeg,image/jpg,image/png, image/gif` func IsSupportedImageFile(file io.Reader, ext string) bool { + ext = strings.TrimPrefix(ext, ".") var err error switch strings.ToUpper(ext) { - case "JPG", "JPEG": - _, err = jpeg.Decode(file) - case "PNG": - _, err = png.Decode(file) + case "JPG", "JPEG", "PNG", "GIF": // only allow for `image/jpeg,image/jpg,image/png, image/gif` + _, _, err = image.Decode(file) case "ICO": // TODO: There is currently no good Golang library to parse whether the image is in ico format. return true