commit eb0418f9817b86b09ca913a93bcf704b376ff97e
parent 1bbf319cf7e63b4bed0d253e89aeb1b5167de8d4
Author: Christoph Lohmann <20h@r-36.net>
Date:   Tue, 28 Nov 2017 19:16:42 +0100
In cas in alternative text/plain is zero length, display html.
Diffstat:
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/part.c b/part.c
@@ -247,7 +247,8 @@ partmain(int argc, char *argv[])
 					status & TOSTDOUT, status & RAW);
 		}
 
-		llist_free(partl);
+		if (partl != NULL)
+			llist_free(partl);
 		mime_free(mime);
 
 		return retc;
diff --git a/view.c b/view.c
@@ -130,7 +130,7 @@ view_printpart(char *id, mime_t *mime, llist_t *dhdrs, llist_t *partl,
 		int options)
 {
 	llistelem_t *delem, *helem, *part;
-	char *hvalue, *textplainid;
+	char *hvalue, *textplainid, *texthtmlid;
 	int didprint, inpartl;
 	llist_t *alpartl, *hlist;
 
@@ -186,14 +186,23 @@ view_printpart(char *id, mime_t *mime, llist_t *dhdrs, llist_t *partl,
 
 		if (!strncasecmp(mime->ct, "multipart/alternative", 21) &&
 				(partl == NULL || inpartl)) {
-			textplainid = NULL;
+			texthtmlid = textplainid = NULL;
 			forllist(mime->parts, part) {
 				if (!strncasecmp(((mime_t *)part->data)->ct,
-						"text/plain", 10)) {
+						"text/plain", 10)
+					&& (((mime_t *)part->data)->bodylen > 0)) {
 					textplainid =
 						((mime_t *)part->data)->partid;
 				}
+				if (!strncasecmp(((mime_t *)part->data)->ct,
+						"text/html", 9)
+					&& (((mime_t *)part->data)->bodylen > 0)) {
+					texthtmlid =
+						((mime_t *)part->data)->partid;
+				}
 			}
+			if (textplainid == NULL && texthtmlid != NULL)
+				textplainid = texthtmlid;
 
 			alpartl = llist_new();
 			if (textplainid != NULL) {