about summary refs log tree commit diff
path: root/mshow.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2021-01-17 23:23:15 +0100
committerLeah Neukirchen <leah@vuxu.org>2021-01-17 23:23:52 +0100
commite96f0707de039d8a58fb6b3d4037a345ae6f31cc (patch)
tree0bb1a1e3dab125b03bd4a976257569637d893678 /mshow.c
parent318ac214f1de06b0ee69106a36368b2d3b2ac902 (diff)
downloadmblaze-e96f0707de039d8a58fb6b3d4037a345ae6f31cc.tar.gz
mblaze-e96f0707de039d8a58fb6b3d4037a345ae6f31cc.tar.xz
mblaze-e96f0707de039d8a58fb6b3d4037a345ae6f31cc.zip
mshow: show last part of multipart/mixed when none matched
This is in conformance with RFC 1341.
Diffstat (limited to 'mshow.c')
-rw-r--r--mshow.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/mshow.c b/mshow.c
index f66e7b2..5ab309a 100644
--- a/mshow.c
+++ b/mshow.c
@@ -336,7 +336,7 @@ nofilter:
 static void
 choose_alternative(struct message *msg, int depth)
 {
-	int n = 1;
+	int n = 0;
 	int m = 0;
 	char *p = Aflag + strlen(Aflag);
 
@@ -363,6 +363,13 @@ choose_alternative(struct message *msg, int depth)
 	}
 	blaze822_free(imsg);
 
+	if (n == 0) {
+		// No part matched, use last part as per RFC1341 7.2.3
+		// "In general, choosing the best type means displaying
+		// only the LAST part that can be displayed."
+		n = m;
+	}
+
 	imsg = 0;
 	while (blaze822_multipart(msg, &imsg))
 		if (--n == 0)