From d203d38de68bf1c25439b70a3c7f64cb95c268db Mon Sep 17 00:00:00 2001 From: Nazar Kanaev Date: Thu, 1 Jul 2021 14:10:22 +0100 Subject: [PATCH] fix empty feed parsing --- doc/changelog.txt | 1 + src/parser/feed.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/changelog.txt b/doc/changelog.txt index 08df8e2..b364784 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -5,6 +5,7 @@ - (fix) handle opml files not following the spec (thanks to @huangnauh for the report) - (fix) pagination in unread/starred feeds (thanks to @Farow for the report) - (fix) handling feeds with non-utf8 encodings (thanks to @fserb for the report) +- (fix) errors caused by empty feeds (thanks to @decke) - (fix) ui tweaks (thanks to @Farow) # v2.0 (2021-04-18) diff --git a/src/parser/feed.go b/src/parser/feed.go index 2d7cc00..bf77764 100644 --- a/src/parser/feed.go +++ b/src/parser/feed.go @@ -18,6 +18,11 @@ type processor func(r io.Reader) (*Feed, error) func sniff(lookup string) (string, processor) { lookup = strings.TrimSpace(lookup) lookup = strings.TrimLeft(lookup, "\x00\xEF\xBB\xBF\xFE\xFF") + + if len(lookup) < 0 { + return "", nil + } + switch lookup[0] { case '<': decoder := xmlDecoder(strings.NewReader(lookup))