Replacing blacklist with blocklist (#15082)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Jesús Espino
2020-07-22 08:30:10 +02:00
коммит произвёл GitHub
родитель fea28821e3
Коммит 30bd506e76
2 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@@ -659,12 +659,12 @@ func AsStringBoolMap(list []string) map[string]bool {
// SanitizeUnicode will remove undesirable Unicode characters from a string.
func SanitizeUnicode(s string) string {
return strings.Map(filterBlacklist, s)
return strings.Map(filterBlocklist, s)
}
// filterBlacklist returns `r` if it is not in the blacklist, otherwise drop (-1).
// Blacklist is taken from https://www.w3.org/TR/unicode-xml/#Charlist
func filterBlacklist(r rune) rune {
// filterBlocklist returns `r` if it is not in the blocklist, otherwise drop (-1).
// Blocklist is taken from https://www.w3.org/TR/unicode-xml/#Charlist
func filterBlocklist(r rune) rune {
const drop = -1
switch r {
case '\u0340', '\u0341': // clones of grave and acute; deprecated in Unicode

Просмотреть файл

@@ -766,8 +766,8 @@ func TestSanitizeUnicode(t *testing.T) {
{name: "ascii only", arg: "Hello There", want: "Hello There"},
{name: "allowed unicode", arg: "Ādam likes Iñtërnâtiônàližætiøn", want: "Ādam likes Iñtërnâtiônàližætiøn"},
{name: "allowed unicode escaped", arg: "\u00eaI like hats\u00e2", want: "êI like hatsâ"},
{name: "blacklist char, don't reverse string", arg: "\u202E2resu", want: "2resu"},
{name: "blacklist chars, scoping musical notation", arg: musicArg, want: musicWant},
{name: "blocklist char, don't reverse string", arg: "\u202E2resu", want: "2resu"},
{name: "blocklist chars, scoping musical notation", arg: musicArg, want: musicWant},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {