Browse Source

remove unnecessary special-casing for ASCII

tags/v1.2.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
baa71ba2be
2 changed files with 6 additions and 18 deletions
  1. 4
    18
      irc/strings.go
  2. 2
    0
      irc/strings_test.go

+ 4
- 18
irc/strings.go View File

@@ -8,7 +8,6 @@ package irc
8 8
 import (
9 9
 	"fmt"
10 10
 	"strings"
11
-	"unicode"
12 11
 
13 12
 	"github.com/oragono/confusables"
14 13
 	"golang.org/x/text/cases"
@@ -192,15 +191,11 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
192 191
 		nick = "*"
193 192
 	}
194 193
 	if nick != "*" {
195
-		// XXX allow nick wildcards in pure ASCII, but not in unicode,
194
+		// XXX wildcards are not accepted with most unicode nicks,
196 195
 		// because the * character breaks casefolding
197
-		if IsPureASCII(nick) {
198
-			nick = strings.ToLower(nick)
199
-		} else {
200
-			nick, err = Casefold(nick)
201
-			if err != nil {
202
-				return "", err
203
-			}
196
+		nick, err = Casefold(nick)
197
+		if err != nil {
198
+			return "", err
204 199
 		}
205 200
 	}
206 201
 	if user == "" {
@@ -217,12 +212,3 @@ func CanonicalizeMaskWildcard(userhost string) (expanded string, err error) {
217 212
 	}
218 213
 	return fmt.Sprintf("%s!%s@%s", nick, user, host), nil
219 214
 }
220
-
221
-func IsPureASCII(str string) bool {
222
-	for i := 0; i < len(str); i++ {
223
-		if unicode.MaxASCII < str[i] {
224
-			return false
225
-		}
226
-	}
227
-	return true
228
-}

+ 2
- 0
irc/strings_test.go View File

@@ -212,4 +212,6 @@ func TestCanonicalizeMaskWildcard(t *testing.T) {
212 212
 	tester("slingamn!", "slingamn!*@*", nil)
213 213
 	tester("shivaram*@good-fortune", "*!shivaram*@good-fortune", nil)
214 214
 	tester("shivaram*", "shivaram*!*@*", nil)
215
+	tester("Shivaram*", "shivaram*!*@*", nil)
216
+	tester("*SHIVARAM*", "*shivaram*!*@*", nil)
215 217
 }

Loading…
Cancel
Save