only need to dupe string for zalgo if zerowidth present

master
Ted Unangst 5 years ago
parent dd522b8243
commit 49d1574575

@ -70,19 +70,30 @@ func unpucker(s string) string {
return string(x) return string(x)
} }
s = re_alltheshitz.ReplaceAllStringFunc(s, fixer) s = re_alltheshitz.ReplaceAllStringFunc(s, fixer)
x := make([]byte, 0, len(s))
zw := false zw := false
for _, c := range s { for _, c := range s {
if runewidth.RuneWidth(c) == 0 { if runewidth.RuneWidth(c) == 0 {
if zw {
continue
}
zw = true zw = true
} else { break
zw = false
} }
q := string(c)
x = append(x, []byte(q)...)
} }
return string(x) if zw {
x := make([]byte, 0, len(s))
zw = false
for _, c := range s {
if runewidth.RuneWidth(c) == 0 {
if zw {
continue
}
zw = true
} else {
zw = false
}
q := string(c)
x = append(x, []byte(q)...)
}
return string(x)
}
return s
} }

Loading…
Cancel
Save