mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
strings: Disallow nicknames that mess with the protocol in bad ways
This commit is contained in:
parent
65539a593b
commit
7ce62444de
@ -1,9 +1,10 @@
|
||||
package irc
|
||||
|
||||
import (
|
||||
"golang.org/x/text/unicode/norm"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/unicode/norm"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -35,7 +36,15 @@ func (name Name) IsChannel() bool {
|
||||
}
|
||||
|
||||
func (name Name) IsNickname() bool {
|
||||
return NicknameExpr.MatchString(name.String())
|
||||
namestr := name.String()
|
||||
// * is used for unregistered clients
|
||||
// , is used as a separator by the protocol
|
||||
// # is a channel prefix
|
||||
// @+ are channel membership prefixes
|
||||
if namestr == "*" || strings.Contains(namestr, ",") || strings.Contains("#@+", string(namestr[0])) {
|
||||
return false
|
||||
}
|
||||
return NicknameExpr.MatchString(namestr)
|
||||
}
|
||||
|
||||
// conversions
|
||||
|
Loading…
Reference in New Issue
Block a user