diff options
Diffstat (limited to 'unread_news.patch')
-rw-r--r-- | unread_news.patch | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/unread_news.patch b/unread_news.patch new file mode 100644 index 000000000000..85c6a695e18a --- /dev/null +++ b/unread_news.patch @@ -0,0 +1,105 @@ +From 5eba7d9b279aea3de4270947d84d619a34093fe4 Mon Sep 17 00:00:00 2001 +From: Olivier Brunel <jjk@jjacky.com> +Date: Mon, 13 Nov 2017 18:18:00 +0100 +Subject: [PATCH] news: Fix issue if title needs trimming.. + +..that is, if a news title (used to determine whether it has been read +or not) could be trimmedg, there was an issue because titles read from +news.conf are trimmed, so the two wouldn't match, and the news +incorrectly considered unread. + +To fix this we trim the titles read from the XML (RSS feed) as well. + +Thanks to Ada Joule; Also adam777 for the report. + +Fixes #57 +--- + src/kalu/news.c | 35 ++++++++++++++++++++++++++++------- + 1 file changed, 28 insertions(+), 7 deletions(-) + +diff --git a/src/kalu/news.c b/src/kalu/news.c +index 49d4058..85deecf 100644 +--- a/src/kalu/news.c ++++ b/src/kalu/news.c +@@ -24,6 +24,7 @@ + + /* C */ + #include <string.h> ++#include <ctype.h> + + #ifndef DISABLE_GUI + /* gtk */ +@@ -121,25 +122,45 @@ xml_parser_updates_text (GMarkupParseContext *context, + + if (streq ("title", list->data)) + { ++ gchar *s = (gchar *) text; ++ ++ /* if it needs trimming, let's do it. (If not we use text as-is to avoid ++ * a possibly unneeded call strdup) */ ++ if (isspace (*s) || isspace (s[strlen (s) - 1])) ++ { ++ s = strtrim (strdup (s)); ++ } ++ + /* is this the last item from last check? */ +- if (NULL != config->news_last && streq (config->news_last, text)) ++ if (NULL != config->news_last && streq (config->news_last, s)) + { + parse_updates_data->is_last_reached = TRUE; ++ if (s != text) ++ { ++ free (s); ++ } + return; + } + + /* was this item already read? */ + FOR_LIST (i, config->news_read) + { +- if (streq (i->data, text)) ++ if (streq (i->data, s)) + { ++ if (s != text) ++ { ++ free (s); ++ } + return; + } + } + + /* add title to the new news */ +- parse_updates_data->titles = alpm_list_add (parse_updates_data->titles, +- strdup (text)); ++ if (s == text) ++ { ++ s = strdup (s); ++ } ++ parse_updates_data->titles = alpm_list_add (parse_updates_data->titles, s); + } + } + +@@ -698,12 +719,12 @@ xml_parser_news_text (GMarkupParseContext *context, + { + /* make a copy of the title, and store it in list of all titles */ + /* it will not be free-d here. this is done on window_destroy_cb */ +- s = strdup (text); ++ s = strtrim (strdup (text)); + lists = parse_news_data->lists; + lists[LIST_TITLES_ALL] = alpm_list_add (lists[LIST_TITLES_ALL], s); + + /* is this the last item from last check? */ +- if (NULL != config->news_last && streq (config->news_last, text)) ++ if (NULL != config->news_last && streq (config->news_last, s)) + { + parse_news_data->is_last_reached = TRUE; + return; +@@ -712,7 +733,7 @@ xml_parser_news_text (GMarkupParseContext *context, + /* was this item already read? */ + FOR_LIST (i, config->news_read) + { +- if (streq (i->data, text)) ++ if (streq (i->data, s)) + { + /* make a note to skip its description as well */ + skip_next_description = TRUE; |