refactor: clean up code and enhance utilities with new functions

This commit is contained in:
yusing
2025-03-28 08:08:33 +08:00
parent 7707fc6f36
commit cdb3ffe439
9 changed files with 103 additions and 17 deletions

View 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, "..")
}