mirror of
https://github.com/jeremyd/ergo.git
synced 2026-04-26 15:40:00 -07:00
strings: disallow ':' in nicks
This matches the behavior of inspircd at the very least. Previously, the comment above that section claimed ':' should be disallowed, but the code didn't do so. I also simplified the code a little bit and added tests.
This commit is contained in:
@@ -44,8 +44,7 @@ func CasefoldChannel(name string) (string, error) {
|
||||
// , is used as a separator
|
||||
// * is used in mask matching
|
||||
// ? is used in mask matching
|
||||
if strings.Contains(lowered, " ") || strings.Contains(lowered, ",") ||
|
||||
strings.Contains(lowered, "*") || strings.Contains(lowered, "?") {
|
||||
if strings.ContainsAny(lowered, " ,*?") {
|
||||
return "", errInvalidCharacter
|
||||
}
|
||||
|
||||
@@ -73,11 +72,7 @@ func CasefoldName(name string) (string, error) {
|
||||
// # is a channel prefix
|
||||
// ~&@%+ are channel membership prefixes
|
||||
// - I feel like disallowing
|
||||
if strings.Contains(lowered, " ") || strings.Contains(lowered, ",") ||
|
||||
strings.Contains(lowered, "*") || strings.Contains(lowered, "?") ||
|
||||
strings.Contains(lowered, ".") || strings.Contains(lowered, "!") ||
|
||||
strings.Contains(lowered, "@") ||
|
||||
strings.Contains("#~&@%+-", string(lowered[0])) {
|
||||
if strings.ContainsAny(lowered, " ,*?.!@:") || strings.ContainsAny(string(lowered[0]), "#~&@%+-") {
|
||||
return "", errInvalidCharacter
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user