mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-13 07:29:30 +01:00
remove unnecessary special-casing for ASCII
This commit is contained in:
parent
607da61bf9
commit
baa71ba2be
@ -8,7 +8,6 @@ package irc
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
|
||||||
|
|
||||||
"github.com/oragono/confusables"
|
"github.com/oragono/confusables"
|
||||||
"golang.org/x/text/cases"
|
"golang.org/x/text/cases"
|
||||||
@ -192,15 +191,11 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
|
|||||||
nick = "*"
|
nick = "*"
|
||||||
}
|
}
|
||||||
if 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
|
// because the * character breaks casefolding
|
||||||
if IsPureASCII(nick) {
|
nick, err = Casefold(nick)
|
||||||
nick = strings.ToLower(nick)
|
if err != nil {
|
||||||
} else {
|
return "", err
|
||||||
nick, err = Casefold(nick)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if user == "" {
|
if user == "" {
|
||||||
@ -217,12 +212,3 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
|
|||||||
}
|
}
|
||||||
return fmt.Sprintf("%s!%s@%s", nick, user, host), nil
|
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("slingamn!", "slingamn!*@*", nil)
|
||||||
tester("shivaram*@good-fortune", "*!shivaram*@good-fortune", nil)
|
tester("shivaram*@good-fortune", "*!shivaram*@good-fortune", nil)
|
||||||
tester("shivaram*", "shivaram*!*@*", nil)
|
tester("shivaram*", "shivaram*!*@*", nil)
|
||||||
|
tester("Shivaram*", "shivaram*!*@*", nil)
|
||||||
|
tester("*SHIVARAM*", "*shivaram*!*@*", nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user