about summary refs log tree commit diff
diff options
context:
space:
mode:
-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;