1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Handle more encoding edge cases

- Feeds with charset specified only in Content-Type header and not in XML document
- Feeds with charset specified in both places
- Feeds with charset specified only in XML document and not in HTTP header
This commit is contained in:
Frédéric Guillot 2018-01-19 22:42:55 -08:00
parent 3b62f904d6
commit 713b38e34c
10 changed files with 87 additions and 21 deletions

View file

@ -10,15 +10,14 @@ import (
"github.com/miniflux/miniflux/errors"
"github.com/miniflux/miniflux/model"
"golang.org/x/net/html/charset"
"github.com/miniflux/miniflux/reader/encoding"
)
// Parse returns a normalized feed struct from a RSS feed.
func Parse(data io.Reader) (*model.Feed, error) {
feed := new(rssFeed)
decoder := xml.NewDecoder(data)
decoder.CharsetReader = charset.NewReaderLabel
decoder.CharsetReader = encoding.CharsetReader
err := decoder.Decode(feed)
if err != nil {