diff --git a/reader/atom/atom_10.go b/reader/atom/atom_10.go index 71e7c697..4b45603b 100644 --- a/reader/atom/atom_10.go +++ b/reader/atom/atom_10.go @@ -227,6 +227,9 @@ type atom10Text struct { XHTMLRootElement atomXHTMLRootElement `xml:"http://www.w3.org/1999/xhtml div"` } +// Text: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1.1.1 +// HTML: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1.1.2 +// XHTML: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1.1.3 func (a *atom10Text) String() string { var content string switch { @@ -237,11 +240,7 @@ func (a *atom10Text) String() string { content = a.InnerXML } case a.Type == "xhtml": - if a.XHTMLRootElement.InnerXML != "" { - content = a.XHTMLRootElement.InnerXML - } else { - content = a.InnerXML - } + content = a.XHTMLRootElement.InnerXML default: content = a.CharData } diff --git a/reader/atom/atom_10_test.go b/reader/atom/atom_10_test.go index 6aec8dbf..51381765 100644 --- a/reader/atom/atom_10_test.go +++ b/reader/atom/atom_10_test.go @@ -339,14 +339,6 @@ func TestParseEntryWithXHTMLTitle(t *testing.T) {
Test
TestTest
Test` {
- t.Errorf("Incorrect entry title, got: %q", feed.Entries[0].Title)
+ if feed.Entries[0].Title != `This is XHTML content.` {
+ t.Errorf("Incorrect entry title, got: %q", feed.Entries[1].Title)
+ }
+}
+
+func TestParseEntryWithEmptyXHTMLTitle(t *testing.T) {
+ data := `
+ Some text.
Some text.
` { - t.Errorf("Incorrect entry content, got: %s", feed.Entries[0].Content) - } - - if feed.Entries[1].Content != `Test: std::unique_ptr<S>
Test: std::unique_ptr<S>