ebd6a11f3a
The server authenticate against an LDAP server.
28 lines
662 B
Go
28 lines
662 B
Go
package utils
|
|
|
|
import (
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// IsFileInputValid returns true this is a valid file name.
|
|
// This method must be used before joining a file name, generally provided as
|
|
// user input, with a directory
|
|
func IsFileInputValid(fileInput string) bool {
|
|
cleanInput := filepath.Clean(fileInput)
|
|
if cleanInput == "." || cleanInput == ".." {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// IsStringPrefixInSlice searches a string prefix in a slice and returns true
|
|
// if a matching prefix is found
|
|
func IsStringPrefixInSlice(obj string, list []string) bool {
|
|
for _, v := range list {
|
|
if strings.HasPrefix(obj, v) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|