|
@@ -7,6 +7,7 @@ package irc
|
7
|
7
|
|
8
|
8
|
import (
|
9
|
9
|
"fmt"
|
|
10
|
+ "regexp"
|
10
|
11
|
"strings"
|
11
|
12
|
"unicode"
|
12
|
13
|
|
|
@@ -21,6 +22,12 @@ const (
|
21
|
22
|
precisUTF8MappingToken = "rfc8265"
|
22
|
23
|
)
|
23
|
24
|
|
|
25
|
+var (
|
|
26
|
+ // reviving the old ergonomadic nickname regex:
|
|
27
|
+ // in permissive mode, allow arbitrary letters, numbers, punctuation, and symbols
|
|
28
|
+ permissiveCharsRegex = regexp.MustCompile(`^[\pL\pN\pP\pS]*$`)
|
|
29
|
+)
|
|
30
|
+
|
24
|
31
|
type Casemapping uint
|
25
|
32
|
|
26
|
33
|
const (
|
|
@@ -271,10 +278,8 @@ func IsPureASCII(str string) bool {
|
271
|
278
|
}
|
272
|
279
|
|
273
|
280
|
func foldPermissive(str string) (result string, err error) {
|
274
|
|
- for _, r := range str {
|
275
|
|
- if unicode.IsSpace(r) || r == 0 {
|
276
|
|
- return "", errInvalidCharacter
|
277
|
|
- }
|
|
281
|
+ if !permissiveCharsRegex.MatchString(str) {
|
|
282
|
+ return "", errInvalidCharacter
|
278
|
283
|
}
|
279
|
284
|
// YOLO
|
280
|
285
|
str = norm.NFD.String(str)
|