Fix parsing items with empty bodies from on-disk RSSyl items
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 30 Apr 2019 21:02:18 +0000 (23:02 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 30 Apr 2019 21:02:18 +0000 (23:02 +0200)
src/plugins/rssyl/parse822.c
src/plugins/rssyl/rssyl_add_item.c

index 1c89c77c943fee50e6c4441eac3adc18c8e242a3..51cb313e8e1d9ab2dc1bf9566a2b5ffcc7fc4607 100644 (file)
@@ -198,6 +198,7 @@ FeedItem *rssyl_parse_folder_item_file(gchar *path)
                        if( !strcmp(lines[i], RSSYL_TEXT_START) ) {
                                debug_print("RSSyl: Leading html tag found at line %d\n", i);
                                past_html_tag = TRUE;
+                               body = g_string_new("");
                                i++;
                                continue;
                        }
@@ -208,12 +209,9 @@ FeedItem *rssyl_parse_folder_item_file(gchar *path)
                                        continue;
                                }
 
-                               if (body) {
+                               if (body->len > 0)
                                        body = g_string_append_c(body, '\n');
-                                       body = g_string_append(body, lines[i]);
-                               } else {
-                                       body = g_string_new(lines[i]);
-                               }
+                               body = g_string_append(body, lines[i]);
 
                                i++;
                        }
@@ -224,7 +222,7 @@ FeedItem *rssyl_parse_folder_item_file(gchar *path)
        }
 
        if (body != NULL ) {
-               if (past_endhtml_tag && body->str != NULL && body->len > 0)
+               if (past_html_tag && past_endhtml_tag && body->str != NULL)
                        feed_item_set_text(item, body->str);
                g_string_free(body, TRUE);
        }
index d22e1dd6221c18aa796f284472dfa586eaf02b5d..c40c9cd60b76771fe8df388f8e0a2e9c1a0da228 100644 (file)
@@ -542,7 +542,8 @@ void rssyl_add_item(RFolderItem *ritem, FeedItem *feed_item)
                        (heading ? heading : ""),
                        (tmpurl ? tmpurl : ""),
                        (tmpurl ? tmpurl : "n/a"),
-                       (text ? text : ""), (text ? "\n" : "") );
+                       (text ? text : ""),
+                       (text && strlen(text) > 0 ? "\n" : "") );
 
        g_free(meta_charset);
        g_free(baseurl);