summaryrefslogtreecommitdiff
path: root/sfeed.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-03-20 13:05:43 +0100
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-03-20 13:05:43 +0100
commitbc594605418654a6304ae86902e999f9dda35c57 (patch)
tree1b533392fe87d985d32e96d621b32f47d49a0d33 /sfeed.c
parent3c79aea2a6bfe7e5256c08e8f762b48d8c58d8e6 (diff)
fix crash with repeated <link href=""> tags in Atom feeds
add some detail to the comments
Diffstat (limited to 'sfeed.c')
-rw-r--r--sfeed.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sfeed.c b/sfeed.c
index 96d3940..7b5d08a 100644
--- 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;