ensure valid utf8

master
Bel LaPointe 2021-01-27 20:37:13 -06:00
parent 72bf715cfe
commit 1b10eac271
1 changed files with 5 additions and 1 deletions

View File

@ -63,7 +63,7 @@ func newItem(i *gofeed.Item, contentFilter, copyright string) (*Item, error) {
item.Content = fmt.Sprintf(`<a href="%s">%s</a><br>%s`, item.Link, item.Title, item.Content)
item.Content = clearBlankLines(item.Content)
item.Content = cleanSpecialCharacters(clearBlankLines(item.Content))
return item, nil
}
@ -120,6 +120,10 @@ func (is Items) Swap(i, j int) {
is[j] = k
}
func cleanSpecialCharacters(s string) string {
return strings.ToValidUTF8(s, "?")
}
func clearBlankLines(s string) string {
r := regexp.MustCompile(`<br/>`)
s = r.ReplaceAllLiteralString(s, "<br>")