MCPcopy Index your code
hub / github.com/apache/answer / IsUnAuthorizedExtension

Function IsUnAuthorizedExtension

pkg/checker/file_type.go:40–43  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
40func 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`

Callers 2

UploadPostFileMethod · 0.92
UploadPostAttachmentMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected