From 6b9d5be734afef410ec27f55f22bcbd8c7a82958 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Thu, 17 Oct 2024 05:05:14 +0200 Subject: [PATCH] Act as if there is an author in the feed when only checking the entry --- entry.go | 16 +++++++++------- feed.go | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/entry.go b/entry.go index 69fdca7..57411d1 100644 --- a/entry.go +++ b/entry.go @@ -34,13 +34,15 @@ type Entry struct { // the atom:entry contains an atom:source element that contains an atom:author // element or, in an Atom Feed Document, the atom:feed element contains an // atom:author element itself. -func (e *Entry) checkAuthors() error { +func (e *Entry) checkAuthors(authorInFeed bool) error { if e.Authors == nil { - if e.Source == nil { - return errors.New("no authors set in entry") - } - if e.Source.Authors == nil { - return errors.New("no authors set in entry") + if !authorInFeed { + if e.Source == nil { + return errors.New("no authors set in entry") + } + if e.Source.Authors == nil { + return errors.New("no authors set in entry") + } } } else { for i, a := range e.Authors { @@ -138,7 +140,7 @@ func (e *Entry) Check() error { } } - if err := e.checkAuthors(); err != nil { + if err := e.checkAuthors(true); err != nil { return fmt.Errorf("entry %v: %v", e.ID.URI, err) } diff --git a/feed.go b/feed.go index 1119fa5..005e9f6 100644 --- a/feed.go +++ b/feed.go @@ -128,7 +128,7 @@ func (f *Feed) Check() error { // least one atom:author element. if f.Authors == nil { for _, e := range f.Entries { - if err := e.checkAuthors(); err != nil { + if err := e.checkAuthors(false); err != nil { return fmt.Errorf("no authors set in feed %v: %v", f.ID.URI, err) } }