Browse Source

fix: do not strip tags in Atom entry title

Frédéric Guillot 1 year ago
parent
commit
9c82e55b98
2 changed files with 15 additions and 5 deletions
  1. 0 2
      internal/reader/atom/atom_10.go
  2. 15 3
      internal/reader/atom/atom_10_test.go

+ 0 - 2
internal/reader/atom/atom_10.go

@@ -9,7 +9,6 @@ import (
 	"strings"
 
 	"miniflux.app/v2/internal/reader/media"
-	"miniflux.app/v2/internal/reader/sanitizer"
 )
 
 // The "atom:feed" element is the document (i.e., top-level) element of
@@ -188,7 +187,6 @@ func (a *Atom10Text) Title() string {
 		content = a.CharData
 	}
 
-	content = sanitizer.StripTags(content)
 	return strings.TrimSpace(content)
 }
 

+ 15 - 3
internal/reader/atom/atom_10_test.go

@@ -492,6 +492,10 @@ func TestParseEntryWithHTMLTitle(t *testing.T) {
 		</title>
 		<link href="http://example.org/c"/>
 	  </entry>
+	  <entry>
+		<title type="html"><![CDATA[Test with self-closing &lt;tag&gt;]]></title>
+		<link href="http://example.org/d"/>
+	  </entry>
 	</feed>`
 
 	feed, err := Parse("https://example.org/", bytes.NewReader([]byte(data)), "10")
@@ -499,7 +503,11 @@ func TestParseEntryWithHTMLTitle(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	if feed.Entries[0].Title != "Code Test" {
+	if len(feed.Entries) != 4 {
+		t.Fatalf("Incorrect number of entries, got: %d", len(feed.Entries))
+	}
+
+	if feed.Entries[0].Title != "<code>Code</code> Test" {
 		t.Errorf("Incorrect entry title, got: %q", feed.Entries[0].Title)
 	}
 
@@ -510,6 +518,10 @@ func TestParseEntryWithHTMLTitle(t *testing.T) {
 	if feed.Entries[2].Title != "Entry title with space around CDATA" {
 		t.Errorf("Incorrect entry title, got: %q", feed.Entries[2].Title)
 	}
+
+	if feed.Entries[3].Title != "Test with self-closing <tag>" {
+		t.Errorf("Incorrect entry title, got: %q", feed.Entries[3].Title)
+	}
 }
 
 func TestParseEntryWithXHTMLTitle(t *testing.T) {
@@ -537,7 +549,7 @@ func TestParseEntryWithXHTMLTitle(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	if feed.Entries[0].Title != `This is XHTML content.` {
+	if feed.Entries[0].Title != `This is <b>XHTML</b> content.` {
 		t.Errorf("Incorrect entry title, got: %q", feed.Entries[0].Title)
 	}
 }
@@ -643,7 +655,7 @@ func TestParseEntryWithDoubleEncodedEntitiesTitle(t *testing.T) {
 		t.Fatal(err)
 	}
 
-	if feed.Entries[0].Title != `'AT&T'` {
+	if feed.Entries[0].Title != `&#39;AT&amp;T&#39;` {
 		t.Errorf("Incorrect entry title, got: %q", feed.Entries[0].Title)
 	}
 }