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>
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"
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
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
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"
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"
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;
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: {
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 {
}
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;
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;
}