1
0
Fork 0
forked from External/ergo
This commit is contained in:
Shivaram Lingamneni 2019-10-10 04:17:44 -04:00
parent cddc51d6cf
commit 332f0d8d91
9 changed files with 166 additions and 98 deletions

View file

@ -8,6 +8,7 @@ package irc
import (
"fmt"
"strings"
"unicode"
"github.com/oragono/confusables"
"golang.org/x/text/cases"
@ -191,9 +192,15 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
nick = "*"
}
if nick != "*" {
nick, err = Casefold(nick)
if err != nil {
return "", err
// XXX allow nick wildcards in pure ASCII, but not in unicode,
// because the * character breaks casefolding
if IsPureASCII(nick) {
nick = strings.ToLower(nick)
} else {
nick, err = Casefold(nick)
if err != nil {
return "", err
}
}
}
if user == "" {
@ -210,3 +217,12 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
}
return fmt.Sprintf("%s!%s@%s", nick, user, host), nil
}
func IsPureASCII(str string) bool {
for i := 0; i < len(str); i++ {
if unicode.MaxASCII < str[i] {
return false
}
}
return true
}