1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-02 16:38:37 +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

@ -9,14 +9,14 @@ import (
"io"
"github.com/miniflux/miniflux/errors"
"golang.org/x/net/html/charset"
"github.com/miniflux/miniflux/reader/encoding"
)
// Parse reads an OPML file and returns a SubcriptionList.
func Parse(data io.Reader) (SubcriptionList, error) {
feeds := new(opml)
decoder := xml.NewDecoder(data)
decoder.CharsetReader = charset.NewReaderLabel
decoder.CharsetReader = encoding.CharsetReader
err := decoder.Decode(feeds)
if err != nil {