summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2018-04-17 15:26:19 +0200
committerLeah Neukirchen <leah@vuxu.org>2018-04-17 15:26:19 +0200
commitd261b0cdcf4c16060630f4f1d1bb9c674f8caf65 (patch)
tree319ee63e610f12bc9890afc878a8ee2492f78fc6
parent5d43ad24048698ba89858648389e7e8479801746 (diff)
downloadmblaze-d261b0cdcf4c16060630f4f1d1bb9c674f8caf65.tar.gz
mblaze-d261b0cdcf4c16060630f4f1d1bb9c674f8caf65.tar.xz
mblaze-d261b0cdcf4c16060630f4f1d1bb9c674f8caf65.zip
mshow: add -B to decode MIME parameters in broken mails
-rw-r--r--man/mshow.19
-rw-r--r--mshow.c10
2 files changed, 16 insertions, 3 deletions
diff --git a/man/mshow.1 b/man/mshow.1
index ec181ee..a71e0cc 100644
--- a/man/mshow.1
+++ b/man/mshow.1
@@ -1,4 +1,4 @@
-.Dd July 22, 2016
+.Dd April 17, 2018
 .Dt MSHOW 1
 .Os
 .Sh NAME
@@ -8,7 +8,7 @@
 .Nm
 .Op Fl h Ar headers
 .Op Fl A Ar mimetypes
-.Op Fl nqrFHLN
+.Op Fl nqrBFHLN
 .Op Ar msgs\ ...
 .Nm
 .Fl x Ar msg
@@ -67,6 +67,11 @@ Don't render the body, stop after header output.
 .It Fl r
 Don't render the body, print raw body.
 This may be dangerous to use on a tty.
+.It Fl B
+Decode encoded-words also in MIME parameters in direct violation
+of RFC 2047.
+This is useful if the attachment names look like
+.Sq Li =?UTF-8?Q?stuff?= .
 .It Fl F
 Don't apply filters to MIME parts.
 .It Fl H
diff --git a/mshow.c b/mshow.c
index edb110b..d4b1ba8 100644
--- a/mshow.c
+++ b/mshow.c
@@ -15,6 +15,7 @@
 
 #include "blaze822.h"
 
+static int Bflag;
 static int rflag;
 static int Rflag;
 static int qflag;
@@ -166,6 +167,12 @@ mime_filename(struct message *msg)
 			filename = buf;
 	}
 
+	if (Bflag && filename) {
+		static char buf2[512];
+		blaze822_decode_rfc2047(buf2, filename, sizeof buf2, "UTF-8");
+		filename = buf2;
+	}
+
 	return filename;
 }
 
@@ -743,10 +750,11 @@ main(int argc, char *argv[])
 	pid_t pid1 = -1, pid2 = -1;
 
 	int c;
-	while ((c = getopt(argc, argv, "h:A:qrtFHLNx:O:Rn")) != -1)
+	while ((c = getopt(argc, argv, "h:A:BqrtFHLNx:O:Rn")) != -1)
 		switch (c) {
 		case 'h': hflag = optarg; break;
 		case 'A': Aflag = optarg; break;
+		case 'B': Bflag = 1; break;
 		case 'q': qflag = 1; break;
 		case 'r': rflag = 1; break;
 		case 'F': Fflag = 1; break;