lib/fs: Ignore normalization differences in case insensitive lookup (fixes #7677) (#7678)

This commit is contained in:
Jakob Borg
2021-05-17 12:35:03 +02:00
committed by GitHub
parent 5b90a98650
commit 97437cad64
7 changed files with 93 additions and 27 deletions
+6 -2
View File
@@ -10,9 +10,13 @@ import (
"strings"
"unicode"
"unicode/utf8"
"golang.org/x/text/unicode/norm"
)
func UnicodeLowercase(s string) string {
// UnicodeLowercaseNormalized returns the Unicode lower case variant of s,
// having also normalized it to normalization form C.
func UnicodeLowercaseNormalized(s string) string {
i := firstCaseChange(s)
if i == -1 {
return s
@@ -28,7 +32,7 @@ func UnicodeLowercase(s string) string {
for _, r := range s[i:] {
rs.WriteRune(unicode.ToLower(unicode.ToUpper(r)))
}
return rs.String()
return norm.NFC.String(rs.String())
}
// Byte index of the first rune r s.t. lower(upper(r)) != r.