mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-28 12:22:12 +01:00
security: sanitize path and uri
This commit is contained in:
11
internal/utils/strutils/filepath.go
Normal file
11
internal/utils/strutils/filepath.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package strutils
|
||||
|
||||
import "strings"
|
||||
|
||||
// IsValidFilename checks if a filename is safe and doesn't contain path traversal attempts
|
||||
// Returns true if the filename is valid, false otherwise
|
||||
func IsValidFilename(filename string) bool {
|
||||
return !strings.Contains(filename, "/") &&
|
||||
!strings.Contains(filename, "\\") &&
|
||||
!strings.Contains(filename, "..")
|
||||
}
|
||||
Reference in New Issue
Block a user