Enha: input check; hash passwords
This commit is contained in:
@@ -5,6 +5,10 @@ import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
const (
|
||||
SaneLengthMax = 20
|
||||
)
|
||||
|
||||
func RemoveSpacesFromStr(origin string) string {
|
||||
return strings.Map(func(r rune) rune {
|
||||
if unicode.IsSpace(r) {
|
||||
@@ -35,3 +39,13 @@ func RemoveFromSlice(key string, sl []string) []string {
|
||||
}
|
||||
return resp
|
||||
}
|
||||
|
||||
func IsInputSane(s string) bool {
|
||||
if len(s) > SaneLengthMax {
|
||||
return false
|
||||
}
|
||||
if strings.ContainsAny(s, "{}?!$&:/[]~") {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user