diff --git a/internal/reader/rss/adapter.go b/internal/reader/rss/adapter.go index df6b6cb9..be5b23b3 100644 --- a/internal/reader/rss/adapter.go +++ b/internal/reader/rss/adapter.go @@ -173,13 +173,13 @@ func findFeedAuthor(rssChannel *RSSChannel) string { } func findEntryTitle(rssItem *RSSItem) string { - title := rssItem.Title + title := sanitizer.StripTags(rssItem.Title.Inner) if rssItem.DublinCoreTitle != "" { title = rssItem.DublinCoreTitle } - return html.UnescapeString(strings.TrimSpace(title)) + return html.UnescapeString(html.UnescapeString(strings.TrimSpace(title))) } func findEntryURL(rssItem *RSSItem) string { diff --git a/internal/reader/rss/parser_test.go b/internal/reader/rss/parser_test.go index 2434335a..50b3f446 100644 --- a/internal/reader/rss/parser_test.go +++ b/internal/reader/rss/parser_test.go @@ -1023,6 +1023,30 @@ func TestParseEntryTitleWithWhitespaces(t *testing.T) { } } +func TestParseEntryTitleWithInnerHTML(t *testing.T) { + data := ` + + + Example + http://example.org + + Test: <b>bold</b> + http://www.example.org/entries/1 + Fri, 15 Jul 2005 00:00:00 -0500 + + + ` + + feed, err := Parse("https://example.org/", bytes.NewReader([]byte(data))) + if err != nil { + t.Fatal(err) + } + + if feed.Entries[0].Title != "Test: bold" { + t.Errorf("Incorrect entry title, got: %s", feed.Entries[0].Title) + } +} + func TestParseEntryWithEnclosures(t *testing.T) { data := ` diff --git a/internal/reader/rss/rss.go b/internal/reader/rss/rss.go index bc99b461..8ac4982f 100644 --- a/internal/reader/rss/rss.go +++ b/internal/reader/rss/rss.go @@ -111,7 +111,7 @@ type RSSImage struct { type RSSItem struct { // Title is the title of the item. - Title string `xml:"rss title"` + Title RSSTitle `xml:"rss title"` // Link is the URL of the item. Link string `xml:"rss link"` @@ -169,6 +169,11 @@ 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"`