[balsa] Decode all RFC-2047-encoded headers
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Decode all RFC-2047-encoded headers
- Date: Sun, 25 Jun 2017 23:05:46 +0000 (UTC)
commit 326a3cc5b9595bf80568c94303c9f0bcbf92301f
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Jun 25 19:04:30 2017 -0400
Decode all RFC-2047-encoded headers
* libbalsa/message.c
(prepend_header_misc): decode header value;
(libbalsa_message_user_hdrs_from_gmime): streamline code.
ChangeLog | 8 ++++++++
libbalsa/message.c | 37 ++++++++++++++++++++-----------------
2 files changed, 28 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8cad840..95ed867 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-06-25 Peter Bloomfield <pbloomfield bellsouth net>
+
+ Decode all RFC-2047-encoded headers
+
+ * libbalsa/message.c
+ (prepend_header_misc): decode header value;
+ (libbalsa_message_user_hdrs_from_gmime): streamline code.
+
2017-06-19 Peter Bloomfield <pbloomfield bellsouth net>
Possible fix for Red Hat Bugzilla #1462546, reported by jamesbdonovan rambler ru
diff --git a/libbalsa/message.c b/libbalsa/message.c
index 85731e7..3e228de 100644
--- a/libbalsa/message.c
+++ b/libbalsa/message.c
@@ -429,9 +429,10 @@ libbalsa_message_set_user_header(LibBalsaMessage * message,
g_strdup(value)));
}
-static void
-prepend_header_misc(const char *name, const char *value,
- gpointer user_data)
+static GList *
+prepend_header_misc(GList *res,
+ const char *name,
+ const char *value)
{
char lcname[28]; /* one byte longer than the longest ignored header */
static const char ignored_headers[] =
@@ -439,22 +440,24 @@ prepend_header_misc(const char *name, const char *value,
"message-id references in-reply-to status lines"
"disposition-notification-to";
unsigned i;
- GList *res = *(GList **)user_data;
- if (!*value)
+
+ if (value[0] == '\0')
/* Empty header */
- return;
+ return res;
+
/* Standard Headers*/
- for(i=0; i<sizeof(lcname)-1 && name[i]; i++)
+ for(i = 0; i < sizeof(lcname) - 1 && name[i] != '\0'; i++) {
lcname[i] = tolower(name[i]);
- if (i < sizeof(lcname)) {
- /* short enough to be on the ignored-headers list */
- lcname[i] = '\0';
- if(strstr(ignored_headers, lcname))
- return;
}
+ lcname[i] = '\0';
+
+ if(strstr(ignored_headers, lcname) != NULL)
+ return res;
- res = g_list_prepend(res, libbalsa_create_hdr_pair(name, g_strdup(value)));
- *(GList **)user_data = res;
+ return
+ g_list_prepend(res,
+ libbalsa_create_hdr_pair(name,
+ g_mime_utils_header_decode_text(value)));
}
/*
@@ -523,9 +526,9 @@ libbalsa_message_user_hdrs_from_gmime(GMimeMessage * message)
hdrlist = g_mime_object_get_header_list (GMIME_OBJECT(message));
if (g_mime_header_list_get_iter (hdrlist, &iter)) {
do {
- prepend_header_misc (g_mime_header_iter_get_name (&iter),
- g_mime_header_iter_get_value (&iter),
- &res);
+ res = prepend_header_misc(res,
+ g_mime_header_iter_get_name (&iter),
+ g_mime_header_iter_get_value (&iter));
} while (g_mime_header_iter_next (&iter));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]