mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
fix extension check
This commit is contained in:
parent
d514865b64
commit
a9dd261702
@ -138,18 +138,23 @@ func Convert(ImgPath string, AllowedTypes []string, QUALITY string) func(c *fibe
|
||||
}
|
||||
|
||||
// check ext
|
||||
// TODO: should remove this function. Check in Nginx.
|
||||
// TODO: may remove this function. Check in Nginx.
|
||||
var allowed = false
|
||||
for _, ext := range AllowedTypes {
|
||||
haystack := strings.ToLower(ImgFilename)
|
||||
needle := strings.ToLower("." + ext)
|
||||
if strings.HasSuffix(haystack, needle) {
|
||||
allowed = true
|
||||
break
|
||||
} else {
|
||||
c.Send("File extension not allowed!")
|
||||
c.SendStatus(403)
|
||||
return
|
||||
allowed = false
|
||||
}
|
||||
}
|
||||
if !allowed {
|
||||
c.Send("File extension not allowed!")
|
||||
c.SendStatus(403)
|
||||
return
|
||||
}
|
||||
|
||||
// Check the original image for existence,
|
||||
if !imageExists(RawImageAbs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user