overflowtext="***",overflowoffset=5
leftadjust,compwidth=9
Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>"
-From:decode
-To:decode
-Cc:decode
-Subject:decode
+From:formatfield="%(putstr(trim(decode{text})))"
+To:formatfield="%(putstr(trim(decode{text})))"
+Cc:formatfield="%(putstr(trim(decode{text})))"
+Subject:formatfield="%(putstr(trim(decode{text})))"
:
%4(year{date})-%02(mon{date})-%02(mday{date}) \
%02(hour{date}):%02(min{date}) \
%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
-%<(zero)%17(decode(friendly{from}))%> %(decode{subject})
+%<(zero)%17(decode(friendly{from}))%> \
+%(putstr(trim(decode{subject})))
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test trailing space handling in format files
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+msgfile=`mhpath b +inbox`
+cat >"$msgfile" <<!
+Subject: =?UTF-8?Q?3_trailing_spaces___?=
+Mime-Version: 1.0
+From: Bob <bob@example.org>
+Date: Wed, 20 Apr 2016 07:38:12 +0200
+Message-Id: <83C58147-7B2B-4B7F-9502-17C1EB9526BC@example.org>
+To: Alice <alice@example.net>
+Content-Type: text/plain; charset=utf-8
+
+The subject line has three trailing spaces, inside the RFC 2047
+encoding. They get removed if we first (decode) and afterwards
+(trim) on diplay.
+!
+
+
+# output has no trailing spaces
+runandcheck "scan -width 80 +inbox l" <<!
+ 11 2016-04-20 07:38 Bob 3 trailing spaces
+!
+
+
+
+runandcheck "show +inbox l" <<!
+Date: Wed, 20 Apr 2016 07:38:12 +0200
+From: Bob <bob@example.org>
+To: Alice <alice@example.net>
+Subject: 3 trailing spaces
+
+part text/plain 145
+The subject line has three trailing spaces, inside the RFC 2047
+encoding. They get removed if we first (decode) and afterwards
+(trim) on diplay.
+!