[Commits] [SCM] claws branch, master, updated. 3.11.1-27-g1b27348

ticho at claws-mail.org ticho at claws-mail.org
Sun Nov 23 22:23:13 CET 2014


The branch, master has been updated
       via  1b273487116c4af93474ff615d2624c823a6e364 (commit)
      from  00cade792bc7ee9059cc43c70376d5877b12bd73 (commit)

Summary of changes:
 src/plugins/rssyl/libfeed/feed.c          |    2 ++
 src/plugins/rssyl/libfeed/feed.h          |    2 ++
 src/plugins/rssyl/libfeed/parser_atom10.c |   16 +++++++++++++++-
 3 files changed, 19 insertions(+), 1 deletion(-)


- Log -----------------------------------------------------------------
commit 1b273487116c4af93474ff615d2624c823a6e364
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Sun Nov 23 22:20:37 2014 +0100

    RSSyl: Convert relative URLs in Atom entries to absolute URLs, using feed's <link> tag, if possible.

diff --git a/src/plugins/rssyl/libfeed/feed.c b/src/plugins/rssyl/libfeed/feed.c
index cc8c49f..ca048eb 100644
--- a/src/plugins/rssyl/libfeed/feed.c
+++ b/src/plugins/rssyl/libfeed/feed.c
@@ -45,6 +45,7 @@ Feed *feed_new(gchar *url)
 	feed->language = NULL;
 	feed->author = NULL;
 	feed->generator = NULL;
+	feed->link = NULL;
 	feed->items = NULL;
 
 	feed->fetcherr = NULL;
@@ -69,6 +70,7 @@ void feed_free(Feed *feed)
 	g_free(feed->language);
 	g_free(feed->author);
 	g_free(feed->generator);
+	g_free(feed->link);
 	g_free(feed->fetcherr);
 	g_free(feed->cookies_path);
 
diff --git a/src/plugins/rssyl/libfeed/feed.h b/src/plugins/rssyl/libfeed/feed.h
index 15ce456..af9fc3b 100644
--- a/src/plugins/rssyl/libfeed/feed.h
+++ b/src/plugins/rssyl/libfeed/feed.h
@@ -38,6 +38,7 @@ struct _Feed {
 	gchar *language;
 	gchar *author;
 	gchar *generator;
+	gchar *link;
 	time_t date;
 
 	guint timeout;
@@ -88,6 +89,7 @@ gchar *feed_get_description(Feed *feed);
 gchar *feed_get_language(Feed *feed);
 gchar *feed_get_author(Feed *feed);
 gchar *feed_get_generator(Feed *feed);
+gchar *feed_get_link(Feed *feed);
 gchar *feed_get_fetcherror(Feed *feed);
 
 gchar *feed_get_cookies_path(Feed *feed);
diff --git a/src/plugins/rssyl/libfeed/parser_atom10.c b/src/plugins/rssyl/libfeed/parser_atom10.c
index e758425..9215e91 100644
--- a/src/plugins/rssyl/libfeed/parser_atom10.c
+++ b/src/plugins/rssyl/libfeed/parser_atom10.c
@@ -47,6 +47,10 @@ void feed_parser_atom10_start(void *data, const gchar *el, const gchar **attr)
 			/* Start of author info for the feed found.
 			 * Set correct location. */
 			ctx->location = FEED_LOC_ATOM10_AUTHOR;
+		} else if( !strcmp(el, "link") ) {
+			/* Link tag for the feed */
+			g_free(ctx->feed->link);
+			ctx->feed->link = g_strdup(feed_parser_get_attribute_value(attr, "href"));
 		} else ctx->location = FEED_LOC_ATOM10_NONE;
 
 	} else if( ctx->depth == 2 ) {
@@ -97,7 +101,7 @@ void feed_parser_atom10_end(void *data, const gchar *el)
 {
 	FeedParserCtx *ctx = (FeedParserCtx *)data;
 	Feed *feed = ctx->feed;
-	gchar *text = NULL;
+	gchar *text = NULL, *tmp;
 
 	if( ctx->str != NULL )
 		text = ctx->str->str;
@@ -126,6 +130,16 @@ void feed_parser_atom10_end(void *data, const gchar *el)
 			 * add a complete item to feed */
 			if( !strcmp(el, "entry") ) {
 
+				/* Fix up URL, if it is relative */
+				if (!strstr("://", ctx->curitem->url) &&
+						ctx->feed->link != NULL) {
+					tmp = g_strconcat(ctx->feed->link,
+							(ctx->curitem->url[0] == '/' ? "" : "/"),
+							ctx->curitem->url, NULL);
+					feed_item_set_url(ctx->curitem, tmp);
+					g_free(tmp);
+				}
+
 				/* append the complete feed item */
 				if( ctx->curitem->id && ctx->curitem->title
 						&& ctx->curitem->date_modified ) {

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list