mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
remove unnecessary special-casing for ASCII
This commit is contained in:
parent
607da61bf9
commit
baa71ba2be
@ -8,7 +8,6 @@ package irc
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/oragono/confusables"
|
||||
"golang.org/x/text/cases"
|
||||
@ -192,15 +191,11 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
|
||||
nick = "*"
|
||||
}
|
||||
if nick != "*" {
|
||||
// XXX allow nick wildcards in pure ASCII, but not in unicode,
|
||||
// XXX wildcards are not accepted with most unicode nicks,
|
||||
// because the * character breaks casefolding
|
||||
if IsPureASCII(nick) {
|
||||
nick = strings.ToLower(nick)
|
||||
} else {
|
||||
nick, err = Casefold(nick)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
nick, err = Casefold(nick)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
if user == "" {
|
||||
@ -217,12 +212,3 @@ 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
|
||||
}
|
||||
|
@ -212,4 +212,6 @@ func TestCanonicalizeMaskWildcard(t *testing.T) {
|
||||
tester("slingamn!", "slingamn!*@*", nil)
|
||||
tester("shivaram*@good-fortune", "*!shivaram*@good-fortune", nil)
|
||||
tester("shivaram*", "shivaram*!*@*", nil)
|
||||
tester("Shivaram*", "shivaram*!*@*", nil)
|
||||
tester("*SHIVARAM*", "*shivaram*!*@*", nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user