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

Do not strip tags for entry title

Some technical blogs have titles like "</some-title>" or "This is some <code>source code</code>".

Miniflux was removing these elements which prevent rendering the title correctly.
This commit is contained in:
Frédéric Guillot 2021-01-03 11:33:10 -08:00 committed by fguillot
parent f0610bdd9c
commit 291bf96d15
7 changed files with 62 additions and 16 deletions

View file

@ -76,7 +76,7 @@ func TestParseJsonFeed(t *testing.T) {
t.Errorf("Incorrect entry URL, got: %s", feed.Entries[1].URL)
}
if feed.Entries[1].Title != "Hello, world!" {
if feed.Entries[1].Title != "https://example.org/initial-post" {
t.Errorf(`Incorrect entry title, got: "%s"`, feed.Entries[1].Title)
}
@ -409,6 +409,33 @@ func TestParseTruncateItemTitle(t *testing.T) {
}
}
func TestParseItemTitleWithXMLTags(t *testing.T) {
data := `{
"version": "https://jsonfeed.org/version/1",
"title": "My Example Feed",
"home_page_url": "https://example.org/",
"feed_url": "https://example.org/feed.json",
"items": [
{
"title": "</example>"
}
]
}`
feed, err := Parse("https://example.org/feed.json", bytes.NewBufferString(data))
if err != nil {
t.Fatal(err)
}
if len(feed.Entries) != 1 {
t.Errorf("Incorrect number of entries, got: %d", len(feed.Entries))
}
if feed.Entries[0].Title != "</example>" {
t.Errorf("Incorrect entry title, got: %s", feed.Entries[0].Title)
}
}
func TestParseInvalidJSON(t *testing.T) {
data := `garbage`
_, err := Parse("https://example.org/feed.json", bytes.NewBufferString(data))