[gmime] Preserve MIME-Version headers
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime] Preserve MIME-Version headers
- Date: Fri, 26 Mar 2010 13:07:57 +0000 (UTC)
commit f1d69aaadf3aa91ae75145e09825f6e5574c76e5
Author: Jeffrey Stedfast <fejj gnome org>
Date: Fri Mar 26 09:07:31 2010 -0400
Preserve MIME-Version headers
2010-03-26 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-message.c (process_header): Return TRUE if we
* match
MIME-Version.
(message_prepend_header): Don't drop MIME-Version headers.
(message_append_header): Same.
(message_set_header): Here too.
(message_get_header): Only return the hard-coded "1.0" value for
MIME-Version if it is not set on the header object.
(message_remove_header): Allow the MIME-Version header to be
removed.
(message_get_headers): Only write our own MIME-Version header if
one isn't already set in the message headers.
(message_write_to_stream): Same here.
ChangeLog | 15 +++++++++++++++
gmime/gmime-message.c | 44 +++++++++++++++++++++-----------------------
2 files changed, 36 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 10333b7..890f2a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-03-26 Jeffrey Stedfast <fejj novell com>
+
+ * gmime/gmime-message.c (process_header): Return TRUE if we match
+ MIME-Version.
+ (message_prepend_header): Don't drop MIME-Version headers.
+ (message_append_header): Same.
+ (message_set_header): Here too.
+ (message_get_header): Only return the hard-coded "1.0" value for
+ MIME-Version if it is not set on the header object.
+ (message_remove_header): Allow the MIME-Version header to be
+ removed.
+ (message_get_headers): Only write our own MIME-Version header if
+ one isn't already set in the message headers.
+ (message_write_to_stream): Same here.
+
2010-02-12 Jeffrey Stedfast <fejj novell com>
Fixes bug #609700.
diff --git a/gmime/gmime-message.c b/gmime/gmime-message.c
index 45e5d4b..638b93e 100644
--- a/gmime/gmime-message.c
+++ b/gmime/gmime-message.c
@@ -669,6 +669,7 @@ enum {
HEADER_SUBJECT,
HEADER_DATE,
HEADER_MESSAGE_ID,
+ HEADER_MIME_VERSION,
HEADER_UNKNOWN
};
@@ -681,6 +682,7 @@ static const char *message_headers[] = {
"Subject",
"Date",
"Message-Id",
+ "MIME-Version",
};
enum {
@@ -772,6 +774,8 @@ process_header (GMimeObject *object, int action, const char *header, const char
g_free (message->message_id);
message->message_id = g_mime_utils_decode_message_id (value);
break;
+ case HEADER_MIME_VERSION:
+ break;
default:
return FALSE;
}
@@ -784,9 +788,6 @@ message_prepend_header (GMimeObject *object, const char *header, const char *val
{
GMimeMessage *message = (GMimeMessage *) object;
- if (!g_ascii_strcasecmp ("MIME-Version", header))
- return;
-
/* Make sure that the header is not a Content-* header, else it
doesn't belong on a message */
if (!g_ascii_strncasecmp ("Content-", header, 8))
@@ -806,9 +807,6 @@ message_append_header (GMimeObject *object, const char *header, const char *valu
{
GMimeMessage *message = (GMimeMessage *) object;
- if (!g_ascii_strcasecmp ("MIME-Version", header))
- return;
-
/* Make sure that the header is not a Content-* header, else it
doesn't belong on a message */
if (!g_ascii_strncasecmp ("Content-", header, 8))
@@ -828,9 +826,6 @@ message_set_header (GMimeObject *object, const char *header, const char *value)
{
GMimeMessage *message = (GMimeMessage *) object;
- if (!g_ascii_strcasecmp ("MIME-Version", header))
- return;
-
/* Make sure that the header is not a Content-* header, else it
doesn't belong on a message */
if (!g_ascii_strncasecmp ("Content-", header, 8))
@@ -849,18 +844,21 @@ static const char *
message_get_header (GMimeObject *object, const char *header)
{
GMimeMessage *message = (GMimeMessage *) object;
-
- if (!g_ascii_strcasecmp ("MIME-Version", header))
- return "1.0";
+ const char *value;
/* Make sure that the header is not a Content-* header, else it
doesn't belong on a message */
- if (g_ascii_strncasecmp ("Content-", header, 8) != 0)
- return GMIME_OBJECT_CLASS (parent_class)->get_header (object, header);
- else if (message->mime_part)
+ if (g_ascii_strncasecmp ("Content-", header, 8) != 0) {
+ if ((value = GMIME_OBJECT_CLASS (parent_class)->get_header (object, header)))
+ return value;
+
+ if (!g_ascii_strcasecmp ("MIME-Version", header))
+ return "1.0";
+ } else if (message->mime_part) {
return g_mime_object_get_header (message->mime_part, header);
- else
- return NULL;
+ }
+
+ return NULL;
}
static gboolean
@@ -871,9 +869,6 @@ message_remove_header (GMimeObject *object, const char *header)
GMimeRecipientType type;
guint i;
- if (!g_ascii_strcasecmp ("MIME-Version", header))
- return FALSE;
-
/* Make sure that the header is not a Content-* header, else it
doesn't belong on a message */
if (!g_ascii_strncasecmp ("Content-", header, 8)) {
@@ -959,7 +954,8 @@ message_get_headers (GMimeObject *object)
} else {
g_mime_header_list_write_to_stream (object->headers, stream);
if (message->mime_part) {
- if (g_mime_object_get_header (message->mime_part, "Content-Type"))
+ if (g_mime_object_get_header (message->mime_part, "Content-Type") &&
+ !g_mime_header_list_get (object->headers, "MIME-Version"))
g_mime_stream_write_string (stream, "MIME-Version: 1.0\n");
g_mime_header_list_write_to_stream (message->mime_part->headers, stream);
}
@@ -986,8 +982,10 @@ message_write_to_stream (GMimeObject *object, GMimeStream *stream)
total += nwritten;
- if ((nwritten = g_mime_stream_write_string (stream, "MIME-Version: 1.0\n")) == -1)
- return -1;
+ if (!g_mime_header_list_get (object->headers, "MIME-Version")) {
+ if ((nwritten = g_mime_stream_write_string (stream, "MIME-Version: 1.0\n")) == -1)
+ return -1;
+ }
total += nwritten;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]