forked from External/ergo
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:
parent
9bb0062dbc
commit
449ef4cea1
2 changed files with 107 additions and 7 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue