mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +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,17 +191,13 @@ 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 = strings.ToLower(nick)
|
|
||||||
} else {
|
|
||||||
nick, err = Casefold(nick)
|
nick, err = Casefold(nick)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if user == "" {
|
if user == "" {
|
||||||
user = "*"
|
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