From: markus schnalke Date: Wed, 20 Apr 2016 06:54:20 +0000 (+0200) Subject: Trim trailing whitespace in scan and show X-Git-Tag: mmh-0.3~44 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=72d6c7764974246384bb5daa7cc8b4f0a516621b;p=mmh Trim trailing whitespace in scan and show This commit fixes the most common scan listings. Still trailing whitespace will be generated by legacy scan listings. The formatfield workaround in etc/mhl.headers is a bit clumsy. Maybe, an mhl variable should be defined for this case ... or better not, to keep the mh-format and the mhl functions orthogonal. --- diff --git a/etc/mhl.headers b/etc/mhl.headers index a398837..87a7752 100644 --- a/etc/mhl.headers +++ b/etc/mhl.headers @@ -7,8 +7,8 @@ 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})))" : diff --git a/etc/scan.default b/etc/scan.default index 902998a..40a0554 100644 --- a/etc/scan.default +++ b/etc/scan.default @@ -5,4 +5,5 @@ %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}))) diff --git a/etc/scan.meillo b/etc/scan.meillo index c809e3b..9001148 100644 --- a/etc/scan.meillo +++ b/etc/scan.meillo @@ -19,4 +19,4 @@ %(void(size))%4(divide 1024)\ %<{mime-version} %|~%>\ \ -%(decode{subject}) +%(putstr(trim(decode{subject}))) diff --git a/test/tests/scan/test-mh-format b/test/tests/scan/test-mh-format new file mode 100644 index 0000000..2771934 --- /dev/null +++ b/test/tests/scan/test-mh-format @@ -0,0 +1,44 @@ +#!/bin/sh +###################################################### +# +# Test trailing space handling in format files +# +###################################################### + +. "$MH_TEST_COMMON" + + +msgfile=`mhpath b +inbox` +cat >"$msgfile" < +Date: Wed, 20 Apr 2016 07:38:12 +0200 +Message-Id: <83C58147-7B2B-4B7F-9502-17C1EB9526BC@example.org> +To: Alice +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" < +To: Alice +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. +!