mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-11 13:28:57 +00:00
fix: sanitize invalid UTF-8 in incoming email, fix widget scroll flicker
This commit is contained in:
@@ -25,6 +25,15 @@ var (
|
||||
regexpConvUUID = regexp.MustCompile(`(?i)\+conv-[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}@`)
|
||||
)
|
||||
|
||||
// SanitizeUTF8 removes NUL bytes and replaces invalid UTF-8 byte sequences with the Unicode replacement character.
|
||||
func SanitizeUTF8(s string) string {
|
||||
if s == "" {
|
||||
return s
|
||||
}
|
||||
s = strings.ReplaceAll(s, "\x00", "")
|
||||
return strings.ToValidUTF8(s, "�")
|
||||
}
|
||||
|
||||
// HTML2Text converts HTML to text.
|
||||
func HTML2Text(html string) string {
|
||||
out, err := html2text.FromString(html, html2text.Options{TextOnly: true})
|
||||
|
||||
Reference in New Issue
Block a user