mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 22:27:44 +00:00
Update vendor, move to labstack/echo/v4 Fixes #698
This commit is contained in:
28
vendor/github.com/shazow/ssh-chat/internal/sanitize/sanitize.go
generated
vendored
Normal file
28
vendor/github.com/shazow/ssh-chat/internal/sanitize/sanitize.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
package sanitize
|
||||
|
||||
import "regexp"
|
||||
|
||||
var reStripName = regexp.MustCompile("[^\\w.-]")
|
||||
|
||||
const maxLength = 16
|
||||
|
||||
// Name returns a name with only allowed characters and a reasonable length
|
||||
func Name(s string) string {
|
||||
s = reStripName.ReplaceAllString(s, "")
|
||||
nameLength := maxLength
|
||||
if len(s) <= maxLength {
|
||||
nameLength = len(s)
|
||||
}
|
||||
s = s[:nameLength]
|
||||
return s
|
||||
}
|
||||
|
||||
var reStripData = regexp.MustCompile("[^[:ascii:]]|[[:cntrl:]]")
|
||||
|
||||
// Data returns a string with only allowed characters for client-provided metadata inputs.
|
||||
func Data(s string, maxlen int) string {
|
||||
if len(s) > maxlen {
|
||||
s = s[:maxlen]
|
||||
}
|
||||
return reStripData.ReplaceAllString(s, "")
|
||||
}
|
Reference in New Issue
Block a user