[Commits] [SCM] claws branch, master, updated. 3.15.0-53-g9056a51

ticho at claws-mail.org ticho at claws-mail.org
Mon May 15 22:24:08 CEST 2017


The branch, master has been updated
       via  9056a51ccd598060bb52d4ef0354410e0c30b58e (commit)
      from  401c6cdb985141d007cafc5c372e42d23add13bb (commit)

Summary of changes:
 src/plugins/rssyl/libfeed/feed.c      |    6 +++++-
 src/plugins/rssyl/libfeed/feed.h      |    1 +
 src/plugins/rssyl/libfeed/parser.c    |   11 +++++++++++
 src/plugins/rssyl/rssyl_update_feed.c |    2 +-
 4 files changed, 18 insertions(+), 2 deletions(-)


- Log -----------------------------------------------------------------
commit 9056a51ccd598060bb52d4ef0354410e0c30b58e
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon May 15 22:22:13 2017 +0200

    RSSyl: Stop earlier when an invalid feed is encountered.
    
    This fixes a bug where feeds get renamed to "Untitled feed"
    if their URL starts serving e.g. a HTML document instead
    of proper content.

diff --git a/src/plugins/rssyl/libfeed/feed.c b/src/plugins/rssyl/libfeed/feed.c
index 10f0a76..c88f87b 100644
--- a/src/plugins/rssyl/libfeed/feed.c
+++ b/src/plugins/rssyl/libfeed/feed.c
@@ -38,6 +38,7 @@ Feed *feed_new(gchar *url)
 	feed = malloc( sizeof(Feed) );
 	g_return_val_if_fail(feed != NULL, NULL);
 
+	feed->is_valid = TRUE;
 	feed->timeout = FEED_DEFAULT_TIMEOUT;
 	feed->url = g_strdup(url);
 	feed->auth = NULL;
@@ -339,8 +340,11 @@ guint feed_update(Feed *feed, time_t last_update)
 	if( res != CURLE_OK ) {
 		feed->fetcherr = g_strdup(curl_easy_strerror(res));
 		response_code = FEED_ERR_FETCH;
-	} else
+	} else if (!feed->is_valid) {
+		response_code = FEED_ERR_NOFEED;
+	} else {
 		curl_easy_getinfo(eh, CURLINFO_RESPONSE_CODE, &response_code);
+	}
 
 cleanup:
 	curl_easy_cleanup(eh);
diff --git a/src/plugins/rssyl/libfeed/feed.h b/src/plugins/rssyl/libfeed/feed.h
index f8df922..c62f462 100644
--- a/src/plugins/rssyl/libfeed/feed.h
+++ b/src/plugins/rssyl/libfeed/feed.h
@@ -46,6 +46,7 @@ struct _FeedAuth {
 struct _Feed {
 	gchar *url;
 	FeedAuth *auth;
+	gboolean is_valid;
 	gchar *title;
 	gchar *description;
 	gchar *language;
diff --git a/src/plugins/rssyl/libfeed/parser.c b/src/plugins/rssyl/libfeed/parser.c
index 68694ab..be9458c 100644
--- a/src/plugins/rssyl/libfeed/parser.c
+++ b/src/plugins/rssyl/libfeed/parser.c
@@ -93,6 +93,9 @@ static void _elparse_start_chooser(void *data,
 				feedtype = FEED_TYPE_ATOM_10;
 			else
 				feedtype = FEED_TYPE_ATOM_03;
+		} else {
+			/* Not a known feed type */
+			ctx->feed->is_valid = FALSE;
 		}
 	}
 
@@ -164,11 +167,19 @@ size_t feed_writefunc(void *ptr, size_t size, size_t nmemb, void *data)
 	FeedParserCtx *ctx = (FeedParserCtx *)data;
 	gint status, err;
 
+	if (!ctx->feed->is_valid) {
+		/* We already know that the feed is not valid, so we won't
+		 * try parsing it. Just return correct number so libcurl is
+		 * happy. */
+		return len;
+	}
+
 	status = XML_Parse(ctx->parser, ptr, len, FALSE);
 
 	if( status == XML_STATUS_ERROR ) {
 		err = XML_GetErrorCode(ctx->parser);
 		printf("\nExpat: --- %s\n\n", XML_ErrorString(err));
+		ctx->feed->is_valid = FALSE;
 	}
 
 	return len;
diff --git a/src/plugins/rssyl/rssyl_update_feed.c b/src/plugins/rssyl/rssyl_update_feed.c
index a9d1129..e74045c 100644
--- a/src/plugins/rssyl/rssyl_update_feed.c
+++ b/src/plugins/rssyl/rssyl_update_feed.c
@@ -134,7 +134,7 @@ void rssyl_fetch_feed(RFetchCtx *ctx, RSSylVerboseFlags verbose)
 
 		ctx->success = FALSE;
 	} else {
-		if( ctx->feed == NULL ) {
+		if( ctx->feed == NULL || ctx->response_code == FEED_ERR_NOFEED) {
 			if( verbose & RSSYL_SHOW_ERRORS) {
 				gchar *msg = g_markup_printf_escaped(
 						(const char *) _("No valid feed found at\n<b>%s</b>"),

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list