3
0
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:
Shivaram Lingamneni 2019-10-23 02:18:45 -04:00
parent 607da61bf9
commit baa71ba2be
2 changed files with 6 additions and 18 deletions

View File

@ -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
}

View File

@ -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)
}