[evolution-rss/evolution-rss-0-2-0] Bug 648490 - arXiv rss feeds: from not shown properly
- From: Lucian Langa <lucilanga src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-rss/evolution-rss-0-2-0] Bug 648490 - arXiv rss feeds: from not shown properly
- Date: Sun, 24 Apr 2011 09:18:16 +0000 (UTC)
commit b83437feddf04cd1c691f03b07afb9fabe13728a
Author: Lucian Langa <lucilanga gnome org>
Date: Sun Apr 24 12:17:51 2011 +0300
Bug 648490 - arXiv rss feeds: from not shown properly
src/parser.c | 30 ++++++++++++++++++++++++++++++
src/parser.h | 1 +
2 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/src/parser.c b/src/parser.c
index 35afc02..2209f2d 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -970,6 +970,30 @@ process_images(gchar *text, gchar *link, gboolean decode, EMFormatHTML *format)
return g_strdup(text);
}
+static void
+saxCharacters (void *user_data, const xmlChar *string, int len)
+{
+ GString *buffer = (GString *)user_data;
+ g_string_append_len(buffer, (gchar *)string, len);
+}
+
+GString*
+rss_strip_html (gchar *string)
+{
+ htmlParserCtxtPtr ctxt;
+ htmlSAXHandlerPtr sax;
+ GString *buffer = g_string_new(NULL);
+
+ sax = g_new0 (htmlSAXHandler, 1);
+ sax->characters = saxCharacters;
+ ctxt = htmlCreatePushParserCtxt
+ (sax, buffer, string, strlen (string), "", XML_CHAR_ENCODING_UTF8);
+ htmlParseChunk (ctxt, string, 0, 1);
+ htmlFreeParserCtxt (ctxt);
+ g_free (sax);
+ return buffer;
+}
+
create_feed *
parse_channel_line(xmlNode *top, gchar *feed_name, RDF *r, gchar **article_uid)
{
@@ -1058,6 +1082,12 @@ parse_channel_line(xmlNode *top, gchar *feed_name, RDF *r, gchar **article_uid)
q = g_strdup(layer_find (top, "author",
layer_find (top, "creator", NULL))); //this catches dc:creator too. wrong!
}
+ if (q) {
+ GString *s = rss_strip_html(q);
+ q = s->str;
+ g_string_free(s, 0);
+ }
+
//we might end with a subject containing nothing but spaces
if (q) g_strstrip (q);
diff --git a/src/parser.h b/src/parser.h
index 793010c..abcb6e9 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -23,6 +23,7 @@
gchar *update_channel(RDF *r);
xmlDoc *rss_html_url_decode(const char *html, int len);
+GString *rss_strip_html (gchar *string);
const char *layer_find (xmlNodePtr node,
const char *match,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]