summaryrefslogtreecommitdiff
path: root/sfeed.c
AgeCommit message (Collapse)Author
2021-01-22sfeed: fix regression with parsing content fieldsHiltjo Posthuma
This regression introduced in commit e43b7a48 on Tue Oct 6 18:51:33 2020 +0200. After a content tag was parsed the "iscontenttag" variable was not reset. This caused 2 regressions: - It ignored other tags such as links after it. - It incorrectly set the content-type of a lesser priority field. Thanks to pazz0 for reporting it!
2020-10-22Do not change the referenced matched tag data (from gettag()).Hiltjo Posthuma
Fixes a regression introduced in the refactor in commit e43b7a48b08a6bbcb4e730e80395b3257681b33e Now copy the data by value. This structure is small and no performance regression has been seen. This was because the tag ID was modified which made subsequent parsed tags of this type behave strangely: ctx.tag->id = RSSTagGuidPermalinkTrue; Input data to reproduce: <rss> <channel> <item> <guid isPermaLink="false">https://def/</guid> </item> <item> <guid>https://abc/</guid> </item> </channel> </rss>
2020-10-12add a comment about the intended date priorityHiltjo Posthuma
2020-10-12Revert "RSS: give Dublin Core <dc:date> higher priority over <pubDate>"Hiltjo Posthuma
This reverts commit a1516cb7869a0dd99ebaacf846ad4161f2b9b9a2.
2020-10-12simplify time parsingHiltjo Posthuma
2020-10-12remove unneeded check for NUL terminatorHiltjo Posthuma
2020-10-12RSS: give Dublin Core <dc:date> higher priority over <pubDate>Hiltjo Posthuma
This way dc:date could be the updated time of the item. For Atom there is <published> and <updated> with the same logic.
2020-10-12parse categories, add multiple field values support (for categories)Hiltjo Posthuma
Fields with multiple values are separated by '|'. In the future multiple enclosure support might be added. The categories tags are now parsed. This feature is useful for filtering and categorizing. Parsing of nested tags such as <author><name> has been improved. This code has been refactored. RSS <guid> isPermaLink is now handled differently also and will now prefer a permalink with "true" (link) over the ID. In practise multiple <guid> in an item does not happen.
2020-10-09sfeed: parse day with max 2 digits (instead of 4)Hiltjo Posthuma
2020-10-09sfeed: support the ISO8601 time format without separatorsHiltjo Posthuma
For example "19720229T132245Z" is now supported.
2020-10-09XML cdata callback: handle CDATA as dataHiltjo Posthuma
This improves handling CDATA for example in Atom feeds with: <author><email><![CDATA[abc]]><name><![CDATA[[person]]></name></author>
2020-05-28sfeed: simplify/optimize checking end tags while inside a RSS/Atom tagHiltjo Posthuma
Instead of a binary search do set a pointer to the assigned expected end tag. This makes more sense and is also a minor optimization. No behavioural change intended.
2020-01-24cleanup some includesHiltjo Posthuma
2020-01-18minor style: use plain int for xml_entitytostr()Hiltjo Posthuma
2019-10-12string_append: check for addition and multiplication overflowHiltjo Posthuma
This could overflow / wrap the buffer. Note: SIZE_MAX is defined in POSIX to atleast 65535. On most platforms on 64-bit this is 0xffffffffffffffffUL bytes.
2019-09-05sfeed.c: fix typo in commentHiltjo Posthuma
2019-06-17sfeed: optimization: xmlattr: when not in some RSS/Atom tag skip further checksHiltjo Posthuma
2019-06-11fix typo in commentHiltjo Posthuma
2019-06-11optimization: only convert entities when we are inside a RSS/Atom tagHiltjo Posthuma
2019-06-11reorder functionHiltjo Posthuma
2019-06-11Handle entities in attribute values.Julian Schweinsberg
2019-05-25gettzoffset: fix possible arithmetic overflow if int is 16-bitHiltjo Posthuma
also reduce size of return type (32-bit+ should be enough).
2019-05-10remove unused variablesHiltjo Posthuma
2019-05-10sfeed: remove support for military zones and simplifyHiltjo Posthuma
see RFC2822 4.3 page 32: " [...] However, because of the error in [RFC822], they SHOULD all be considered equivalent to "-0000" unless there is out-of-band information confirming their meaning. "
2019-05-02sfeed: improve content type (attribute) handlingHiltjo Posthuma
- handle type attribute for MRSS media:description, media:description type="plain" is now parsed properly. - handle default content-types per tag now. - when multiple content-like fields are specified use the proper content-type. - be flexible about type attribute handling. - minor code tweaks.
2019-04-14sfeed: add support for the first enclosure of an itemHiltjo Posthuma
This is useful for example for podcasts (audio attachment), newsposts (usually some image) or comic strips (link to page, image as enclosure). thanks leot for the feedback!
2019-04-06optimization: define GETNEXT as an inline macroHiltjo Posthuma
This reduces much function call overhead. getnext is defined in xml.h for inline optimization. sfeed only uses one XML parser context per program, this allows further optimizations of the compiler also. On OpenBSD it was noticable because of retpoline etc function call overhead. Using clang and a 500MB test XML file reduces processing time from +- 12s to 5s. Tested using some crazy optimization flags: SFEED_CFLAGS = -O3 -std=c99 -DGETNEXT=getchar_unlocked -fno-ret-protector \ -mno-retpoline -static A GETNEXT macro is also nice for programs which mmap(2) some big XML file. Then you can simply define: #define GETNEXT() (off >= len ? EOF : reg[off++])
2019-04-06sfeed: gettag: simplify and use ANSI bsearch()Hiltjo Posthuma
2019-03-03gettzoffset: bit more strict UTC offset parsingHiltjo Posthuma
2019-03-03skip spaces in parsetime() itselfHiltjo Posthuma
2019-03-03sfeed: style, break in switch instead of returnHiltjo Posthuma
this style change is useful for my local coverage profile.
2019-02-27atomlinktype make enum TagId instead of intHiltjo Posthuma
2019-02-27improve RSS2 permalink supportHiltjo Posthuma
In RSS2 (but not RSS0.9), a <link> is optional and it can also be specified by <guid isPermaLink="true"> (permalink is "true" by default). When a <link> is also present this will be used instead of the GUID permalink.
2019-02-27sfeed.c: improve commentHiltjo Posthuma
2019-02-24stricter Atom link parsingHiltjo Posthuma
the Atom link parsing is more strict now and checks the rel attribute. When the rel attribute is empty it is handled as a normal link ("alternate"). This makes sure when an link with an other type is specified (such as "enclosure", "related", "self" or "via") before a link it is not used. sfeed does not handle enclosures, but the code is reworked so it is very simple to add this. Enclosures are often used for example to attach some image to a newspost or an audio file to a podcast.
2019-02-24fix RFC822 ANSI and military zones parsingHiltjo Posthuma
2019-02-08don't read XML data inside tag for Atom <link href/>Hiltjo Posthuma
Noticed in the webcomic "amphibian": http://amphibian.com/feeds/atom
2019-02-08trim whitespace around uri field valueHiltjo Posthuma
... and abstract printing timetamp and uri to string_print_{timestamp,uri} similar to string_print_trimmed (normal string) and string_print_encoded (content). Noticed with whitespace around the field in the webcomic "amphibian": http://amphibian.com/feeds/atom
2019-02-08short some callback variable names, change "name" to "t" (tag)Hiltjo Posthuma
2019-01-29sfeed: use the same handler names as the XMLParserHiltjo Posthuma
2018-12-14sfeed: rename buffer to buf, change entitytostr check, it can never happenHiltjo Posthuma
2018-10-08improve code-style for parsing timeHiltjo Posthuma
- reorder and remove a goto. - no need for a separate variable "end". - don't use s[0] style because the pointer was changed.
2018-10-05sfeed: parsetime: weekday part in RFC822 time is optionalHiltjo Posthuma
noticed in "RMS notes" RSS.
2018-09-07fix many undefined behaviour in usage of ctype functionsHiltjo Posthuma
- cast all ctype(3) function argument to (unsigned char) to avoid UB POSIX says: "The c argument is an int, the value of which the application shall ensure is a character representable as an unsigned char or equal to the value of the macro EOF. If the argument has any other value, the behavior is undefined." Many libc cast implicitly the value, but NetBSD does not, which is probably the correct thing to interpret it. - no need to cast for putchar + rename some fputc(..., stdout) to putchar POSIX says: "The fputc() function shall write the byte specified by c (converted to an unsigned char) to the output stream pointed to by stream [...]" Major thanks to Leonardo Taccari <iamleot@gmail.com> for reporting and testing it on NetBSD!
2018-08-22remove stdint.h includeHiltjo Posthuma
the uint* types in XML are not exposed anymore.
2018-03-11include <sys/types.h> for types size_t, ssize_t etcHiltjo Posthuma
This makes sure xml.c in particular can be compiled without further feature macros.
2017-04-27improve gettag()Hiltjo Posthuma
2017-04-27simplify pledge stubHiltjo Posthuma
2016-08-06add USE_PLEDGE, remove pledge dummy functionHiltjo Posthuma
2016-08-06gettzoffset: simplify, default is 0 so remove UTC zones to checkHiltjo Posthuma