more sanitize

This commit is contained in:
André Roth
2024-10-11 13:37:33 +02:00
parent 7742980426
commit cefc09a41b
5 changed files with 22 additions and 15 deletions

View File

@@ -24,9 +24,11 @@ func DirIsAccessible(filename string) error {
return nil
}
// Remove leading '/', remove '..'
func PathSanitize(path string) (result string) {
// Remove leading '/', remove '..', '$' and '`'
func SanitizePath(path string) (result string) {
result = strings.Replace(path, "..", "", -1)
result = strings.Replace(result, "$", "", -1)
result = strings.Replace(result, "`", "", -1)
result = strings.TrimLeft(result, "/")
return
}