From: markus schnalke Date: Wed, 20 Apr 2016 07:02:06 +0000 (+0200) Subject: Fix order of (trim) and (decode) in repl*comps X-Git-Tag: mmh-0.3~43 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=f3575c51862ea3ef58aa9acae72505054d510143;p=mmh Fix order of (trim) and (decode) in repl*comps Before MH had (decode), the format escapes used to be: %(void{comp})%(trim)%(putstr) i.e. set the internal str register to the component text, trim trailing whitespace from it, then print the value. Later (putstr) was simply replaced by (decode), which first RFC-2047 decodes the string and then prints it (if it is the outermost function). That almost always produced the correct result. But this way the whitespace trimming is done at the wrong point. Correct is to first decode the string and then trim it. tests/scan/test-mh-format checks for that. --- diff --git a/etc/replcomps b/etc/replcomps index 5c98142..5230700 100644 --- a/etc/replcomps +++ b/etc/replcomps @@ -20,18 +20,18 @@ %(formataddr(me))\ %(void(width))%(void(decode))%(putaddr Cc: ) Fcc: +sent -Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%> +Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%> %; %; Make References: and In-reply-to: fields for threading. -%; Use (void), (trim) and (putstr) to eat trailing whitespace. +%; Use (trim) to eat trailing whitespace. %; %<{message-id}In-reply-to: %{message-id}\n%>\ %<{message-id}References: \ -%<{references}%(void{references})%(trim)%(putstr) %>\ -%(void{message-id})%(trim)%(putstr)\n%>\ +%<{references}%(trim{references})%(putstr) %>\ +%(trim{message-id})%(putstr)\n%>\ Comments: In-reply-to \ %<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\ -%(trim)%(decode)\n\ +%(putstr(trim(decode)))\n\ message dated "%<(nodate{date})%{date}%|%(tws{date})%>." -------- [%4(year{date})-%02(mon{date})-%02(mday{date}) \ diff --git a/etc/replgroupcomps b/etc/replgroupcomps index ffbe6ff..09d6360 100644 --- a/etc/replgroupcomps +++ b/etc/replgroupcomps @@ -29,18 +29,18 @@ %<(nonnull)%(void(width))%(void(decode))%(putaddr Cc: )\n%>%>\ %; Fcc: +sent -Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%> +Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%> %; %; Make References: and In-reply-to: fields for threading. -%; Use (void), (trim) and (putstr) to eat trailing whitespace. +%; Use (trim) to eat trailing whitespace. %; %<{message-id}In-reply-to: %{message-id}\n%>\ %<{message-id}References: \ -%<{references}%(void{references})%(trim)%(putstr) %>\ -%(void{message-id})%(trim)%(putstr)\n%>\ +%<{references}%(trim{references})%(putstr) %>\ +%(trim{message-id})%(putstr)\n%>\ Comments: In-reply-to \ %<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\ -%(trim)%(decode)\n\ +%(putstr(trim(decode)))\n\ message dated "%<(nodate{date})%{date}%|%(tws{date})%>." -------- [%4(year{date})-%02(mon{date})-%02(mday{date}) \ diff --git a/man/mh-format.man5 b/man/mh-format.man5 index 20b3937..ed0a2dc 100644 --- a/man/mh-format.man5 +++ b/man/mh-format.man5 @@ -215,6 +215,13 @@ or .I str is used as the argument: which register is used depends on the function, as listed below. +.\" What is the difference between these two lines: +.\" %(void{comp})%(trim)%(putstr) +.\" %(putstr(trim{comp})) +.\" The latter can be used as a single expression for %<. +.\" It does make a difference for (decode) because in the former +.\" way, wrapping (decode) with (void) can be necessary. +.\" What is the prefered way? .PP Component escapes write the value of their message header in .IR str .