mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-10-27 06:47:01 +00:00
merges main into feat-whatsapp
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/k3a/html2text"
|
||||
"github.com/jaytaylor/html2text"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -31,9 +31,22 @@ func NormalizeWhatsAppPhone(s string) string {
|
||||
return waPhoneFormatting.Replace(s)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return strings.TrimSpace(html2text.HTML2Text(html))
|
||||
out, err := html2text.FromString(html, html2text.Options{TextOnly: true})
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(out)
|
||||
}
|
||||
|
||||
// SanitizeFilename sanitizes the provided filename.
|
||||
|
||||
Reference in New Issue
Block a user