Browse Source

Accept HTML entities when parsing XML

Every once in a while, one of my feeds would throw an XML parse error
because it used ` ` or some other HTML entity. I feel Miniflux
should be lenient here, and Go already has a handy hook to make this
work.
Peter De Wachter 7 months ago
parent
commit
3a39d110f0
5 changed files with 5 additions and 0 deletions
  1. 1 0
      reader/atom/parser.go
  2. 1 0
      reader/opml/parser.go
  3. 1 0
      reader/parser/format.go
  4. 1 0
      reader/rdf/parser.go
  5. 1 0
      reader/rss/parser.go

+ 1 - 0
reader/atom/parser.go

@@ -17,6 +17,7 @@ import (
 func Parse(data io.Reader) (*model.Feed, *errors.LocalizedError) {
 	atomFeed := new(atomFeed)
 	decoder := xml.NewDecoder(data)
+	decoder.Entity = xml.HTMLEntity
 	decoder.CharsetReader = encoding.CharsetReader
 
 	err := decoder.Decode(atomFeed)

+ 1 - 0
reader/opml/parser.go

@@ -16,6 +16,7 @@ import (
 func Parse(data io.Reader) (SubcriptionList, *errors.LocalizedError) {
 	feeds := new(opml)
 	decoder := xml.NewDecoder(data)
+	decoder.Entity = xml.HTMLEntity
 	decoder.CharsetReader = encoding.CharsetReader
 
 	err := decoder.Decode(feeds)

+ 1 - 0
reader/parser/format.go

@@ -27,6 +27,7 @@ func DetectFeedFormat(data string) string {
 	}
 
 	decoder := xml.NewDecoder(strings.NewReader(data))
+	decoder.Entity = xml.HTMLEntity
 	decoder.CharsetReader = encoding.CharsetReader
 
 	for {

+ 1 - 0
reader/rdf/parser.go

@@ -17,6 +17,7 @@ import (
 func Parse(data io.Reader) (*model.Feed, *errors.LocalizedError) {
 	feed := new(rdfFeed)
 	decoder := xml.NewDecoder(data)
+	decoder.Entity = xml.HTMLEntity
 	decoder.CharsetReader = encoding.CharsetReader
 
 	err := decoder.Decode(feed)

+ 1 - 0
reader/rss/parser.go

@@ -17,6 +17,7 @@ import (
 func Parse(data io.Reader) (*model.Feed, *errors.LocalizedError) {
 	feed := new(rssFeed)
 	decoder := xml.NewDecoder(data)
+	decoder.Entity = xml.HTMLEntity
 	decoder.CharsetReader = encoding.CharsetReader
 
 	err := decoder.Decode(feed)