1
0
mirror of https://github.com/shazow/ssh-chat.git synced 2025-07-09 21:21:06 +03:00
2015-01-20 14:13:59 -08:00

18 lines
462 B
Go

package chat
import "regexp"
var reStripName = regexp.MustCompile("[^\\w.-]")
// SanitizeName returns a name with only allowed characters.
func SanitizeName(s string) string {
return reStripName.ReplaceAllString(s, "")
}
var reStripData = regexp.MustCompile("[^[:ascii:]]")
// SanitizeData returns a string with only allowed characters for client-provided metadata inputs.
func SanitizeData(s string) string {
return reStripData.ReplaceAllString(s, "")
}