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

Improve XML decoder to remove illegal characters

This commit is contained in:
Tony Wang 2019-10-23 11:27:27 +08:00 committed by Frédéric Guillot
parent 7409bba0d8
commit 2eb2441f2b
7 changed files with 85 additions and 19 deletions

View file

@ -5,22 +5,17 @@
package atom // import "miniflux.app/reader/atom"
import (
"encoding/xml"
"io"
"miniflux.app/errors"
"miniflux.app/model"
"miniflux.app/reader/encoding"
"miniflux.app/reader/xml"
)
// Parse returns a normalized feed struct from a Atom feed.
func Parse(data io.Reader) (*model.Feed, *errors.LocalizedError) {
atomFeed := new(atomFeed)
decoder := xml.NewDecoder(data)
decoder.Entity = xml.HTMLEntity
decoder.Strict = false
decoder.CharsetReader = encoding.CharsetReader
err := decoder.Decode(atomFeed)
if err != nil {
return nil, errors.NewLocalizedError("Unable to parse Atom feed: %q", err)