2007-11-26 [colin] 3.1.0cvs28
authorColin Leroy <colin@colino.net>
Mon, 26 Nov 2007 07:49:49 +0000 (07:49 +0000)
committerColin Leroy <colin@colino.net>
Mon, 26 Nov 2007 07:49:49 +0000 (07:49 +0000)
* src/messageview.c
* src/procmime.c
Handle broken disposition-notifications from Evolution
(http://bugzilla.gnome.org/show_bug.cgi?id=499145)

ChangeLog
PATCHSETS
configure.ac
src/messageview.c
src/procmime.c

index f97c4abd6ae75c5066b64f09f6578a6f8486530e..bce87ad7c13834fc2c0eaee2d8fa12c7dd12632a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-11-26 [colin]     3.1.0cvs28
+
+       * src/messageview.c
+       * src/procmime.c
+               Handle broken disposition-notifications from Evolution
+               (http://bugzilla.gnome.org/show_bug.cgi?id=499145)
+
 2007-11-25 [paul]      3.1.0cvs27
 
        * src/folder_item_prefs.c
index 003a88b9f5393c38175b3f8cebc84de67c312d77..8312c1cde05ec4669b47ac0dcc6c78e2048f17e9 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.204.2.154 -r 1.204.2.155 src/prefs_common.c;  cvs diff -u -r 1.103.2.99 -r 1.103.2.100 src/prefs_common.h;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/prefs_summary_open.c;  cvs diff -u -r 1.1.2.2 -r 1.1.2.3 src/prefs_summary_open.h;  cvs diff -u -r 1.395.2.338 -r 1.395.2.339 src/summaryview.c;  ) > 3.1.0cvs25.patchset
 ( cvs diff -u -r 1.75.2.51 -r 1.75.2.52 src/matcher.c;  cvs diff -u -r 1.39.2.15 -r 1.39.2.16 src/matcher.h;  cvs diff -u -r 1.25.2.32 -r 1.25.2.33 src/matcher_parser_parse.y;  cvs diff -u -r 1.43.2.64 -r 1.43.2.65 src/prefs_matcher.c;  ) > 3.1.0cvs26.patchset
 ( cvs diff -u -r 1.2.2.24 -r 1.2.2.25 src/folder_item_prefs.c;  cvs diff -u -r 1.2.2.12 -r 1.2.2.13 src/folder_item_prefs.h;  ) > 3.1.0cvs27.patchset
+( cvs diff -u -r 1.94.2.164 -r 1.94.2.165 src/messageview.c;  cvs diff -u -r 1.49.2.103 -r 1.49.2.104 src/procmime.c;  ) > 3.1.0cvs28.patchset
index 568bae653182cce396e499f87d04b010ee216eb3..c39e2f1f607bf39fcb4db7c32faf1733de3f738f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=1
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=27
+EXTRA_VERSION=28
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 74d00292c9041c0062470e0774e328b8c0549202..4ac31f879c05696269ee7fff475b3f9c0a0b355e 100644 (file)
@@ -893,6 +893,14 @@ static gint disposition_notification_send(MsgInfo *msginfo)
                        "Original-Message-ID: <%s>\n"
                        "Disposition: manual-action/MDN-sent-manually; displayed\n"
                        "\n"
+                       "--%s\n"
+                       "Content-Type: application/octet-stream\n"
+                       "Reporting-UA: %s\n"
+                       "Original-Recipient: rfc822;%s\n"
+                       "Final-Recipient: rfc822;%s\n"
+                       "Original-Message-ID: <%s>\n"
+                       "Disposition: manual-action/MDN-sent-manually; displayed\n"
+                       "\n"
                        "--%s--\n", 
                        boundary, 
                        boundary,
@@ -905,6 +913,11 @@ static gint disposition_notification_send(MsgInfo *msginfo)
                        orig_to?orig_to:"No To:",
                        account->address,
                        msginfo->msgid?msginfo->msgid:"NO MESSAGE ID",
+                       boundary,
+                       PROG_VERSION,
+                       orig_to?orig_to:"No To:",
+                       account->address,
+                       msginfo->msgid?msginfo->msgid:"NO MESSAGE ID",
                        boundary) < 0) {
                fclose(fp);
                g_unlink(tmp);
index 4420c203ff32cdc2f4213846d79097e1263c305f..79cfeaeaaac302c4df61d8c4dddc8599b3815b63 100644 (file)
@@ -1280,6 +1280,8 @@ static int procmime_parse_mimepart(MimeInfo *parent,
                             gchar *content_id,
                             gchar *content_disposition,
                             gchar *content_location,
+                            const gchar *original_msgid,
+                            const gchar *disposition_notification_hdr,
                             const gchar *filename,
                             guint offset,
                             guint length,
@@ -1300,6 +1302,10 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
                                                   NULL, TRUE},
                                {"MIME-Version:",
                                                   NULL, TRUE},
+                               {"Original-Message-ID:",
+                                                  NULL, TRUE},
+                               {"Disposition:",
+                                                  NULL, TRUE},
                                {NULL,             NULL, FALSE}};
        guint content_start, i;
        FILE *fp;
@@ -1335,6 +1341,17 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
                 g_free(hentry[5].body);
                 hentry[5].body = tmp;
         }                
+       if (hentry[7].body != NULL) {
+                tmp = conv_unmime_header(hentry[7].body, NULL);
+                g_free(hentry[7].body);
+                hentry[7].body = tmp;
+        }
+       if (hentry[8].body != NULL) {
+                tmp = conv_unmime_header(hentry[8].body, NULL);
+                g_free(hentry[8].body);
+                hentry[8].body = tmp;
+        }
+  
        content_start = ftell(fp);
        fclose(fp);
        
@@ -1345,6 +1362,7 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
                                hentry[0].body, hentry[1].body,
                                hentry[2].body, hentry[3].body,
                                hentry[4].body, hentry[5].body,
+                               hentry[7].body, hentry[8].body, 
                                mimeinfo->data.filename, content_start,
                                len, short_scan);
        
@@ -1354,7 +1372,9 @@ static void procmime_parse_message_rfc822(MimeInfo *mimeinfo, gboolean short_sca
        }
 }
 
-static void procmime_parse_disposition_notification(MimeInfo *mimeinfo, gboolean short_scan)
+static void procmime_parse_disposition_notification(MimeInfo *mimeinfo, 
+               const gchar *original_msgid, const gchar *disposition_notification_hdr,
+               gboolean short_scan)
 {
        HeaderEntry hentry[] = {{"Original-Message-ID:",  NULL, TRUE},
                                {"Disposition:",          NULL, TRUE},
@@ -1366,15 +1386,25 @@ static void procmime_parse_disposition_notification(MimeInfo *mimeinfo, gboolean
 
        procmime_decode_content(mimeinfo);
 
+       debug_print("parse disposition notification\n");
        fp = g_fopen(mimeinfo->data.filename, "rb");
        if (fp == NULL) {
                FILE_OP_ERROR(mimeinfo->data.filename, "fopen");
                return;
        }
        fseek(fp, mimeinfo->offset, SEEK_SET);
-       procheader_get_header_fields(fp, hentry);
+
+       if (original_msgid && disposition_notification_hdr) {
+               hentry[0].body = g_strdup(original_msgid);
+               hentry[1].body = g_strdup(disposition_notification_hdr);
+       } else {
+               procheader_get_header_fields(fp, hentry);
+       }
 
        if (!hentry[0].body || !hentry[1].body) {
+               debug_print("MsgId %s, Disp %s\n",
+                       hentry[0].body ? hentry[0].body:"(nil)",
+                       hentry[1].body ? hentry[1].body:"(nil)");
                goto bail;
        }
 
@@ -1412,6 +1442,40 @@ bail:
        }
 }
 
+#define GET_HEADERS() {                                                \
+       procheader_get_header_fields(fp, hentry);               \
+        if (hentry[0].body != NULL) {                          \
+                tmp = conv_unmime_header(hentry[0].body, NULL);        \
+                g_free(hentry[0].body);                                \
+                hentry[0].body = tmp;                          \
+        }                                                      \
+        if (hentry[2].body != NULL) {                          \
+                tmp = conv_unmime_header(hentry[2].body, NULL);        \
+                g_free(hentry[2].body);                                \
+                hentry[2].body = tmp;                          \
+        }                                                      \
+        if (hentry[4].body != NULL) {                          \
+                tmp = conv_unmime_header(hentry[4].body, NULL);        \
+                g_free(hentry[4].body);                                \
+                hentry[4].body = tmp;                          \
+        }                                                      \
+        if (hentry[5].body != NULL) {                          \
+                tmp = conv_unmime_header(hentry[5].body, NULL);        \
+                g_free(hentry[5].body);                                \
+                hentry[5].body = tmp;                          \
+        }                                                      \
+       if (hentry[6].body != NULL) {                           \
+                tmp = conv_unmime_header(hentry[6].body, NULL);        \
+                g_free(hentry[6].body);                                \
+                hentry[6].body = tmp;                          \
+        }                                                      \
+       if (hentry[7].body != NULL) {                           \
+                tmp = conv_unmime_header(hentry[7].body, NULL);        \
+                g_free(hentry[7].body);                                \
+                hentry[7].body = tmp;                          \
+        }                                                      \
+}
+
 static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
 {
        HeaderEntry hentry[] = {{"Content-Type:",  NULL, TRUE},
@@ -1425,6 +1489,10 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
                                                   NULL, TRUE},
                                {"Content-Location:",
                                                   NULL, TRUE},
+                               {"Original-Message-ID:",
+                                                  NULL, TRUE},
+                               {"Disposition:",
+                                                  NULL, TRUE},
                                {NULL,             NULL, FALSE}};
        gchar *p, *tmp;
        gchar *boundary;
@@ -1460,43 +1528,24 @@ static void procmime_parse_multipart(MimeInfo *mimeinfo, gboolean short_scan)
                                                        hentry[0].body, hentry[1].body,
                                                        hentry[2].body, hentry[3].body, 
                                                        hentry[4].body, hentry[5].body,
+                                                       hentry[6].body, hentry[7].body,
                                                        mimeinfo->data.filename, lastoffset,
                                                        len, short_scan);
                                if (result == 1 && short_scan) {
                                        done = TRUE;
                                        break;
                                }
-                       }
+                       } 
                        
                        if (buf[2 + boundary_len]     == '-' &&
-                           buf[2 + boundary_len + 1] == '-')
+                           buf[2 + boundary_len + 1] == '-') {
                                break;
-
+                       }
                        for (i = 0; i < (sizeof hentry / sizeof hentry[0]) ; i++) {
                                g_free(hentry[i].body);
                                hentry[i].body = NULL;
                        }
-                       procheader_get_header_fields(fp, hentry);
-                        if (hentry[0].body != NULL) {
-                                tmp = conv_unmime_header(hentry[0].body, NULL);
-                                g_free(hentry[0].body);
-                                hentry[0].body = tmp;
-                        }                
-                        if (hentry[2].body != NULL) {
-                                tmp = conv_unmime_header(hentry[2].body, NULL);
-                                g_free(hentry[2].body);
-                                hentry[2].body = tmp;
-                        }                
-                        if (hentry[4].body != NULL) {
-                                tmp = conv_unmime_header(hentry[4].body, NULL);
-                                g_free(hentry[4].body);
-                                hentry[4].body = tmp;
-                        }                
-                        if (hentry[5].body != NULL) {
-                                tmp = conv_unmime_header(hentry[5].body, NULL);
-                                g_free(hentry[5].body);
-                                hentry[5].body = tmp;
-                        }                
+                       GET_HEADERS();
                        lastoffset = ftell(fp);
                }
        }
@@ -1787,6 +1836,8 @@ static int procmime_parse_mimepart(MimeInfo *parent,
                             gchar *content_id,
                             gchar *content_disposition,
                             gchar *content_location,
+                            const gchar *original_msgid,
+                            const gchar *disposition_notification_hdr,
                             const gchar *filename,
                             guint offset,
                             guint length,
@@ -1872,14 +1923,23 @@ static int procmime_parse_mimepart(MimeInfo *parent,
                                procmime_parse_message_rfc822(mimeinfo, short_scan);
                        }
                        if (g_ascii_strcasecmp(mimeinfo->subtype, "disposition-notification") == 0) {
-                               procmime_parse_disposition_notification(mimeinfo, short_scan);
+                               procmime_parse_disposition_notification(mimeinfo, 
+                                       original_msgid, disposition_notification_hdr, short_scan);
                        }
                        break;
                        
                case MIMETYPE_MULTIPART:
                        procmime_parse_multipart(mimeinfo, short_scan);
                        break;
-                       
+               
+               case MIMETYPE_APPLICATION:
+                       if (g_ascii_strcasecmp(mimeinfo->subtype, "octet-stream") == 0
+                       && original_msgid && *original_msgid 
+                       && disposition_notification_hdr && *disposition_notification_hdr) {
+                               procmime_parse_disposition_notification(mimeinfo, 
+                                       original_msgid, disposition_notification_hdr, short_scan);
+                       }
+                       break;
                default:
                        break;
                }