Spurious empty <summary> elements in atom feed
magical opened this issue ยท 12 comments
I have a feed in which items have a non-empty Content but an empty Description. This should result in an atom feed with a <content>
element for the item but no <summary>
element, but it seems that the feeds package always emits a <summary>
element, even if it is empty.
https://play.golang.org/p/gE3aNOkeIqb
The feeds package should not should not emit a <summary>
element if Item.Content
is set but Item.Description
is blank. Its presence may mislead feed readers into displaying the (empty) summary, ignoring the post content.
I'm currently working around the issue like this, but would prefer if this wasn't necessary.
atomFeed := (&feeds.Atom{feed}).AtomFeed()
for i := range atomFeed.Entries {
atomFeed.Entries[i].Summary = nil
}
Versions
Go version:
go version go1.14.3 linux/amd64
package version:6f6e20dd3953594cd869cf981fb806440685cd21
Steps to Reproduce
How can the bug be triggered?
See code snippet below.
Output:
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>A blog</title>
<id>http://example.net/</id>
<updated>2009-11-10T23:00:00Z</updated>
<link href="http://example.net/"></link>
<author>
<name>Test User</name>
<email>foo@example.net</email>
</author>
<entry>
<title>Blog post</title>
<updated>2009-11-10T23:00:00Z</updated>
<id>tag:example.net,2009-11-10:/1</id>
<content type="html">Full contents of the blog post</content>
<link href="http://example.net/1" rel="alternate"></link>
<summary type="html"></summary>
<author>
<name>Test User</name>
<email>test@example.net</email>
</author>
</entry>
</feed>
Expected behavior
What output or behaviour were you expecting instead?
Expected output
<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
<title>A blog</title>
<id>http://example.net/</id>
<updated>2009-11-10T23:00:00Z</updated>
<link href="http://example.net/"></link>
<author>
<name>Test User</name>
<email>foo@example.net</email>
</author>
<entry>
<title>Blog post</title>
<updated>2009-11-10T23:00:00Z</updated>
<id>tag:example.net,2009-11-10:/1</id>
<content type="html">Full contents of the blog post</content>
<link href="http://example.net/1" rel="alternate"></link>
<author>
<name>Test User</name>
<email>test@example.net</email>
</author>
</entry>
</feed>
Code Snippets
https://play.golang.org/p/gE3aNOkeIqb
package main
import (
"log"
"os"
"time"
"github.com/gorilla/feeds"
)
func main() {
now := time.Now()
feed := &feeds.Feed{
Title: "A blog",
Link: &feeds.Link{Href: "http://example.net/"},
Author: &feeds.Author{Name: "Test User", Email: "foo@example.net"},
Created: now,
}
feed.Items = []*feeds.Item{
&feeds.Item{
Title: "Blog post",
Link: &feeds.Link{Href: "http://example.net/1"},
Content: "Full contents of the blog post",
Author: &feeds.Author{Name: "Test User", Email: "test@example.net"},
Created: now,
},
}
err := feed.WriteAtom(os.Stdout)
if err != nil {
log.Fatal(err)
}
}
If you'd like to submit a PR with tests, I'd be happy to review and merge.
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.
still an issue
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.
Poke
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.
Bump. Happy anniversary.
This issue has been automatically marked as stale because it hasn't seen a recent update. It'll be automatically closed in a few days.
poke
Preemptively poking this before stalebot gets to it.