]> diplodocus.org Git - nmh/commitdiff
Added application/ics to default list if types to decode.
authorDavid Levine <levinedl@acm.org>
Sat, 27 Feb 2016 16:33:39 +0000 (11:33 -0500)
committerDavid Levine <levinedl@acm.org>
Sat, 27 Feb 2016 16:41:36 +0000 (11:41 -0500)
man/mhfixmsg.man
test/mhfixmsg/test-mhfixmsg
uip/mhfixmsg.c

index dd97fe8a2c5c415bbd37318dfd7b6da58f771799..72522777e4fa63ae3fb5cb98e5b4c0e47dddfbf0 100644 (file)
@@ -1,4 +1,4 @@
-.TH MHFIXMSG %manext1% "February 24, 2016" "%nmhversion%"
+.TH MHFIXMSG %manext1% "February 27, 2016" "%nmhversion%"
 .\"
 .\" %nmhwarning%
 .\"
@@ -420,7 +420,7 @@ is checked.
 .RB ` +folder "' defaults to the current folder"
 .RB ` msgs "' defaults to cur"
 .RB ` "\-decodetext 8bit"'
-.RB ` "\-decodetypes text"'
+.RB ` "\-decodetypes text,application/ics"'
 .RB ` \-crlflinebreaks '
 .RB ` \-notextcharset '
 .RB ` \-reformat '
index 77de37da7fb42953b3b20cc0b98bbc361116093f..5ea79adaeb6c1ae529d0cb6c3def7b6c49054b2b 100755 (executable)
@@ -1346,13 +1346,13 @@ Content-Transfer-Encoding: 8bit
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset="iso-8859-1"; name="test2.txt"
+Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
 Content-Disposition: attachment; filename="test2.txt"
 Content-Transfer-Encoding: 8bit
 
 <html>
 <head>
-    This is the text/html part.
+    This was the text/html part.
 </head>
 </body>
 </html>
@@ -1376,16 +1376,16 @@ Content-Transfer-Encoding: quoted-printable
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/plain; charset="iso-8859-1"; name="test2.txt"
+Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
 Content-Disposition: attachment; filename="test2.txt"
 Content-Transfer-Encoding: base64
 
-PGh0bWw+CjxoZWFkPgogICAgVGhpcyBpcyB0aGUgdGV4dC9odG1sIHBhcnQuCjwvaGVhZD4KPC9i
-b2R5Pgo8L2h0bWw+Cg==
+PGh0bWw+CjxoZWFkPgogICAgVGhpcyB3YXMgdGhlIHRleHQvaHRtbCBwYXJ0Lgo8L2hlYWQ+Cjwv
+Ym9keT4KPC9odG1sPgo=
 
 ------- =_aaaaaaaaaa0--
 EOF
-run_prog mhfixmsg last -outfile "$actual"
+run_prog mhfixmsg last -outfile "$actual" -noreformat
 check "$expected" "$actual"
 
 
@@ -1406,15 +1406,32 @@ Content-Transfer-Encoding: 8bit
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
-Content-Type: multipart/alternative; boundary="----=_nmh-multipart2"
+Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
+Content-Disposition: attachment; filename="test2.txt"
+Content-Transfer-Encoding: base64
 
-------=_nmh-multipart2
-Content-Type: text/plain; charset="iso-8859-1"; name="test2.txt"
-Content-Transfer-Encoding: 8bit
+PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
+CjwvYm9keT4NCjwvaHRtbD4NCg==
+
+------- =_aaaaaaaaaa0--
+EOF
+
+cat >`mhpath new` <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhfixmsg decode test 4
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
-This is the text/html part.
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Disposition: attachment; filename="test1.txt"
+Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
+Content-Transfer-Encoding: quoted-printable
+
+This is the text/plain part.
 
-------=_nmh-multipart2
+------- =_aaaaaaaaaa0
 Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
 Content-Disposition: attachment; filename="test2.txt"
 Content-Transfer-Encoding: base64
@@ -1422,7 +1439,45 @@ Content-Transfer-Encoding: base64
 PGh0bWw+DQo8aGVhZD4NCiAgICBUaGlzIGlzIHRoZSB0ZXh0L2h0bWwgcGFydC4NCjwvaGVhZD4N
 CjwvYm9keT4NCjwvaHRtbD4NCg==
 
-------=_nmh-multipart2--
+------- =_aaaaaaaaaa0--
+EOF
+run_prog mhfixmsg last -outfile "$actual" -decodetypes text/plain -noreformat
+check "$expected" "$actual"
+
+
+# check -decodetypes attachment/ics
+# -nocrlflinebreaks won't with non-text content, so the carriage returns are
+# unavoidable.
+cat >$expected <<EOF
+To: recipient@example.com
+From: sender@example.com
+Subject: mhfixmsg decode test 5
+MIME-Version: 1.0
+Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
+
+------- =_aaaaaaaaaa0
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Disposition: attachment; filename="test1.txt"
+Content-MD5: kq+Hnc2SD/eKwAnkFBDuEA==
+Content-Transfer-Encoding: 8bit
+
+This is the text/plain part.
+
+------- =_aaaaaaaaaa0
+Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
+Content-Disposition: attachment; filename="invite.ics"
+Content-Transfer-Encoding: 8bit
+
+BEGIN:VCALENDAR\r
+VERSION:2.0\r
+PRODID:test-mhical\r
+BEGIN:VEVENT\r
+DTSTAMP:20150101T162400Z\r
+DTSTART:20150105T160000\r
+DTEND:20150105T163000\r
+SUMMARY:4 pm meeting\r
+END:VEVENT\r
+END:VCALENDAR\r
 
 ------- =_aaaaaaaaaa0--
 EOF
@@ -1430,7 +1485,7 @@ EOF
 cat >`mhpath new` <<EOF
 To: recipient@example.com
 From: sender@example.com
-Subject: mhfixmsg decode test 4
+Subject: mhfixmsg decode test 5
 MIME-Version: 1.0
 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
 
@@ -1443,16 +1498,18 @@ Content-Transfer-Encoding: quoted-printable
 This is the text/plain part.
 
 ------- =_aaaaaaaaaa0
-Content-Type: text/html; charset="iso-8859-1"; name="test2.txt"
-Content-Disposition: attachment; filename="test2.txt"
+Content-Type: application/ics; charset="iso-8859-1"; name="invite.ics"
+Content-Disposition: attachment; filename="invite.ics"
 Content-Transfer-Encoding: base64
 
-PGh0bWw+CjxoZWFkPgogICAgVGhpcyBpcyB0aGUgdGV4dC9odG1sIHBhcnQuCjwvaGVhZD4KPC9i
-b2R5Pgo8L2h0bWw+Cg==
+QkVHSU46VkNBTEVOREFSDQpWRVJTSU9OOjIuMA0KUFJPRElEOnRlc3QtbWhpY2FsDQpCRUdJTjpW
+RVZFTlQNCkRUU1RBTVA6MjAxNTAxMDFUMTYyNDAwWg0KRFRTVEFSVDoyMDE1MDEwNVQxNjAwMDAN
+CkRURU5EOjIwMTUwMTA1VDE2MzAwMA0KU1VNTUFSWTo0IHBtIG1lZXRpbmcNCkVORDpWRVZFTlQN
+CkVORDpWQ0FMRU5EQVINCg==
 
 ------- =_aaaaaaaaaa0--
 EOF
-run_prog mhfixmsg last -outfile "$actual" -decodetypes text/plain
+run_prog mhfixmsg last -outfile "$actual" -noreformat
 check "$expected" "$actual"
 
 
index 2dd3ef2016688f07e7d80646337f2f4305d00ff8..8a586182c599380ada477e48fbbd77a39e9a8b73 100644 (file)
@@ -142,7 +142,7 @@ main (int argc, char **argv) {
     fx.fixtypes = NULL;
     fx.replacetextplain = 0;
     fx.decodetext = CE_8BIT;
-    fx.decodetypes = "text";  /* Default to all text content. */
+    fx.decodetypes = "text,application/ics";  /* Default, per man page. */
     fx.lf_line_endings = 0;
     fx.textcharset = NULL;
 
@@ -1792,15 +1792,38 @@ set_ct_type (CT ct, int type, int subtype, int encoding) {
 static int
 decode_text_parts (CT ct, int encoding, const char *decodetypes, int *message_mods) {
     int status = OK;
+    int lf_line_endings = 0;
 
     switch (ct->c_type) {
-    case CT_TEXT: {
-        struct text *const text_content_info = (struct text *) ct->c_ctparams;
+    case CT_MULTIPART: {
+        struct multipart *m = (struct multipart *) ct->c_ctparams;
+        struct part *part;
+
+        /* Should check to see if the body for this part is encoded?
+           For now, it gets passed along as-is by InitMultiPart(). */
+        for (part = m->mp_parts; status == OK  &&  part; part = part->mp_next) {
+            status = decode_text_parts (part->mp_part, encoding, decodetypes, message_mods);
+        }
+        break;
+    }
 
+    case CT_MESSAGE:
+        if (ct->c_subtype == MESSAGE_EXTERNAL) {
+            struct exbody *e = (struct exbody *) ct->c_ctparams;
+
+            status = decode_text_parts (e->eb_content, encoding, decodetypes, message_mods);
+        }
+        break;
+
+    default:
         if (! should_decode(decodetypes, ct->c_ctinfo.ci_type, ct->c_ctinfo.ci_subtype)) {
             break;
         }
 
+        lf_line_endings =
+            ct->c_type == CT_TEXT  &&  ct->c_ctparams  &&
+            ((struct text *) ct->c_ctparams)->lf_line_endings;
+
         switch (ct->c_encoding) {
         case CE_BASE64:
         case CE_QUOTED: {
@@ -1852,7 +1875,7 @@ decode_text_parts (CT ct, int encoding, const char *decodetypes, int *message_mo
                             report (NULL, ct->c_partno, ct->c_file, "decode%s",
                                     ct->c_ctline ? ct->c_ctline : "");
                         }
-                        if (text_content_info  &&  text_content_info->lf_line_endings) {
+                        if (lf_line_endings) {
                             strip_crs (ct, message_mods);
                         }
                     } else {
@@ -1866,7 +1889,7 @@ decode_text_parts (CT ct, int encoding, const char *decodetypes, int *message_mo
         }
         case CE_8BIT:
         case CE_7BIT:
-            if (text_content_info  &&  text_content_info->lf_line_endings) {
+            if (lf_line_endings) {
                 strip_crs (ct, message_mods);
             }
             break;
@@ -1877,30 +1900,6 @@ decode_text_parts (CT ct, int encoding, const char *decodetypes, int *message_mo
         break;
     }
 
-    case CT_MULTIPART: {
-        struct multipart *m = (struct multipart *) ct->c_ctparams;
-        struct part *part;
-
-        /* Should check to see if the body for this part is encoded?
-           For now, it gets passed along as-is by InitMultiPart(). */
-        for (part = m->mp_parts; status == OK  &&  part; part = part->mp_next) {
-            status = decode_text_parts (part->mp_part, encoding, decodetypes, message_mods);
-        }
-        break;
-    }
-
-    case CT_MESSAGE:
-        if (ct->c_subtype == MESSAGE_EXTERNAL) {
-            struct exbody *e = (struct exbody *) ct->c_ctparams;
-
-            status = decode_text_parts (e->eb_content, encoding, decodetypes, message_mods);
-        }
-        break;
-
-    default:
-        break;
-    }
-
     return status;
 }