Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious empty <summary> elements in atom feed #82

Closed
magical opened this issue Aug 18, 2020 · 12 comments · Fixed by #83
Closed

Spurious empty <summary> elements in atom feed #82

magical opened this issue Aug 18, 2020 · 12 comments · Fixed by #83
Labels

Comments

@magical
Copy link
Contributor

magical commented Aug 18, 2020

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)
	}
}
@magical magical added the bug label Aug 18, 2020
@elithrar
Copy link
Contributor

If you'd like to submit a PR with tests, I'd be happy to review and merge.

@elithrar elithrar self-assigned this Aug 18, 2020
magical added a commit to magical/feeds that referenced this issue Aug 18, 2020
When creating an AtomEntry from an Item, only set Summary if
item.Description is non-empty, like we already do for Content.

Currently we always emit a <summary> element, even if the item has a
non-empty <content> element. Having an empty <summary> in this case may
be confusing for feed consumers.

The Atom RFC explicitly says that a <summary> is not required in general.
(There are a couple special cases where it is required, but they aren't
relevant here.)

https://tools.ietf.org/html/rfc4287#section-4.1.1.1

Fixes gorilla#82
@stale
Copy link

stale bot commented Oct 17, 2020

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.

@stale stale bot added the stale label Oct 17, 2020
@magical
Copy link
Contributor Author

magical commented Oct 17, 2020

Ping @elithrar would you mind looking at the pull request?

@stale stale bot removed the stale label Oct 17, 2020
@stale
Copy link

stale bot commented Dec 19, 2020

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.

@stale stale bot added the stale label Dec 19, 2020
@magical
Copy link
Contributor Author

magical commented Dec 19, 2020

still an issue

@stale stale bot removed the stale label Dec 19, 2020
@stale
Copy link

stale bot commented Jun 2, 2021

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.

@stale stale bot added the stale label Jun 2, 2021
@magical
Copy link
Contributor Author

magical commented Jun 2, 2021

Poke

@stale stale bot removed the stale label Jun 2, 2021
@stale
Copy link

stale bot commented Aug 22, 2021

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.

@stale stale bot added the stale label Aug 22, 2021
@magical
Copy link
Contributor Author

magical commented Aug 22, 2021

Bump. Happy anniversary.

@stale stale bot removed the stale label Aug 22, 2021
@stale
Copy link

stale bot commented Jan 9, 2022

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.

@stale stale bot added the stale label Jan 9, 2022
@magical
Copy link
Contributor Author

magical commented Jan 15, 2022

poke

@stale stale bot removed the stale label Jan 15, 2022
@magical
Copy link
Contributor Author

magical commented Apr 16, 2022

Preemptively poking this before stalebot gets to it.

@gorilla gorilla deleted a comment Jul 2, 2022
@elithrar elithrar removed their assignment Jul 7, 2023
@coreydaley coreydaley moved this to 🏗 In progress in Gorilla Web Toolkit Jul 23, 2023
coreydaley added a commit that referenced this issue Aug 17, 2023
When creating an AtomEntry from an Item, only set Summary if
item.Description is non-empty, like we already do for Content.

Currently we always emit a `<summary>` element, even if the item has a
non-empty `<content>` element. Having an empty `<summary>` in this case
may
be confusing for feed consumers.

The Atom RFC explicitly says that a `<summary>` is not required in
general.
(There are a couple special cases where it is required, but they aren't
relevant here.)

https://tools.ietf.org/html/rfc4287#section-4.1.1.1

Fixes #82

Co-authored-by: Corey Daley <cdaley@redhat.com>
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Gorilla Web Toolkit Aug 17, 2023
Bios-Marcel pushed a commit to Bios-Marcel/feeds that referenced this issue Apr 27, 2024
When creating an AtomEntry from an Item, only set Summary if
item.Description is non-empty, like we already do for Content.

Currently we always emit a `<summary>` element, even if the item has a
non-empty `<content>` element. Having an empty `<summary>` in this case
may
be confusing for feed consumers.

The Atom RFC explicitly says that a `<summary>` is not required in
general.
(There are a couple special cases where it is required, but they aren't
relevant here.)

https://tools.ietf.org/html/rfc4287#section-4.1.1.1

Fixes gorilla#82

Co-authored-by: Corey Daley <cdaley@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

2 participants