1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

Handle atom feed with space around CDATA

Trim space around CDATA elements before extracting the CharData.

This problem was discovered when reading https://www.sethvargo.com/feed.xml.
Title and Summary fields have newlines and space between the <title>
element and the CDATA element. e.g.

  <title>
    <![CDATA[Entry title here]]>
  </title>

This meant the title of the feed was coming into MiniFlux as,
  <![CDATA[Entry title here]]>
This commit is contained in:
Adrian Smith 2022-01-17 21:31:11 +00:00 committed by Frédéric Guillot
parent 7b0a4a7803
commit cc3e65dd3c
2 changed files with 15 additions and 2 deletions

View file

@ -229,10 +229,9 @@ type atom10Text struct {
func (a *atom10Text) String() string {
var content string
switch {
case a.Type == "", a.Type == "text", a.Type == "text/plain":
if strings.HasPrefix(a.InnerXML, `<![CDATA[`) {
if strings.HasPrefix(strings.TrimSpace(a.InnerXML), `<![CDATA[`) {
content = html.EscapeString(a.CharData)
} else {
content = a.InnerXML