From baa71ba2bef5e123e15f634b6062f4a910393514 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 23 Oct 2019 02:18:45 -0400 Subject: [PATCH] remove unnecessary special-casing for ASCII --- irc/strings.go | 22 ++++------------------ irc/strings_test.go | 2 ++ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/irc/strings.go b/irc/strings.go index 67c144d1..e7ec40ea 100644 --- a/irc/strings.go +++ b/irc/strings.go @@ -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 -} diff --git a/irc/strings_test.go b/irc/strings_test.go index f3d9aeb0..fdf7ddde 100644 --- a/irc/strings_test.go +++ b/irc/strings_test.go @@ -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) }