sfeed

simple feed reader - forked from git.codemadness.org/sfeed
git clone git://src.gearsix.net/sfeed
Log | Files | Refs | Atom | README | LICENSE

commit bc594605418654a6304ae86902e999f9dda35c57
parent 3c79aea2a6bfe7e5256c08e8f762b48d8c58d8e6
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 20 Mar 2016 13:05:43 +0100

fix crash with repeated <link href=""> tags in Atom feeds

add some detail to the comments

Diffstat:
Msfeed.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sfeed.c b/sfeed.c @@ -491,10 +491,11 @@ xml_handler_attr(XMLParser *p, const char *tag, size_t taglen, ctx.contenttype = ContentTypeHTML; } } else if (ctx.tagid == AtomTagLink && - isattr(name, namelen, STRP("href"))) + isattr(name, namelen, STRP("href")) && + ctx.field) { /* link href attribute */ - string_append(&ctx.fields[FeedFieldLink].str, value, valuelen); + string_append(ctx.field, value, valuelen); } } } @@ -601,7 +602,7 @@ xml_handler_start_el(XMLParser *p, const char *name, size_t namelen) return; } - /* field tagid already set: return */ + /* field tagid already set, nested tags are not allowed: return */ if (ctx.tagid) return; @@ -609,7 +610,8 @@ xml_handler_start_el(XMLParser *p, const char *name, size_t namelen) tagid = gettag(ctx.feedtype, name, namelen); ctx.tagid = tagid; - /* map tag type to field: unknown or less priority is ignored. */ + /* map tag type to field: unknown or lesser priority is ignored, + when tags of the same type are repeated only the first is used. */ if (tagid <= ctx.fields[fieldmap[ctx.tagid]].tagid) { ctx.field = NULL; return;