IsUnAuthorizedExtension check whether the file extension is not in the allowedExtensions WANING Only checks the file extension is not reliable, but `http.DetectContentType` and `mimetype` are not reliable for all file types.
(fileName string, allowedExtensions []string)
| 38 | // IsUnAuthorizedExtension check whether the file extension is not in the allowedExtensions |
| 39 | // WANING Only checks the file extension is not reliable, but `http.DetectContentType` and `mimetype` are not reliable for all file types. |
| 40 | func IsUnAuthorizedExtension(fileName string, allowedExtensions []string) bool { |
| 41 | ext := strings.ToLower(strings.Trim(filepath.Ext(fileName), ".")) |
| 42 | return !slices.Contains(allowedExtensions, ext) |
| 43 | } |
| 44 | |
| 45 | // DecodeAndCheckImageFile currently answers support image type is |
| 46 | // `image/jpeg, image/jpg, image/png, image/gif, image/webp` |
no outgoing calls
no test coverage detected