ensure valid utf8
parent
72bf715cfe
commit
1b10eac271
|
|
@ -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 = 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
|
return item, nil
|
||||||
}
|
}
|
||||||
|
|
@ -120,6 +120,10 @@ func (is Items) Swap(i, j int) {
|
||||||
is[j] = k
|
is[j] = k
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanSpecialCharacters(s string) string {
|
||||||
|
return strings.ToValidUTF8(s, "?")
|
||||||
|
}
|
||||||
|
|
||||||
func clearBlankLines(s string) string {
|
func clearBlankLines(s string) string {
|
||||||
r := regexp.MustCompile(`<br/>`)
|
r := regexp.MustCompile(`<br/>`)
|
||||||
s = r.ReplaceAllLiteralString(s, "<br>")
|
s = r.ReplaceAllLiteralString(s, "<br>")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue