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

fix(rss): handle item title with CDATA content correctly

Fix regression introduced in commit a3ce03cc
This commit is contained in:
Frédéric Guillot 2025-02-15 14:46:04 -08:00
parent a3ce03cc9d
commit 7f54b27079
3 changed files with 205 additions and 164 deletions

View file

@ -111,7 +111,7 @@ type RSSImage struct {
type RSSItem struct {
// Title is the title of the item.
Title RSSTitle `xml:"rss title"`
Title InnerContent `xml:"rss title"`
// Link is the URL of the item.
Link string `xml:"rss link"`
@ -169,11 +169,6 @@ type RSSItem struct {
googleplay.GooglePlayItemElement
}
type RSSTitle struct {
Data string `xml:",chardata"`
Inner string `xml:",innerxml"`
}
type RSSAuthor struct {
XMLName xml.Name
Data string `xml:",chardata"`
@ -203,3 +198,28 @@ type RSSSource struct {
URL string `xml:"url,attr"`
Name string `xml:",chardata"`
}
type InnerContent struct {
Content string
}
func (ic *InnerContent) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var content strings.Builder
for {
token, err := d.Token()
if err != nil {
return err
}
switch t := token.(type) {
case xml.CharData:
content.Write(t)
case xml.EndElement:
if t == start.End() {
ic.Content = strings.TrimSpace(content.String())
return nil
}
}
}
}