From: markus schnalke Date: Tue, 6 Sep 2016 17:53:20 +0000 (+0200) Subject: Add %(unmailto) format function for List-Post headers X-Git-Tag: mmh-0.4~66 X-Git-Url: http://git.marmaro.de/?p=mmh;a=commitdiff_plain;h=fc9279e818dfc96c63a5d75a89080cc68cfe1170;ds=sidebyside Add %(unmailto) format function for List-Post headers With the unmailto format function it is possible to extract the address from a List-Post header, which e.g. is: List-Post: Applying %(unmailto{list-post}) extracts: ``mmh@marmaro.de'', which then can be used as recipient address for list replies. A format file (to be used with ``repl -form repllistcomps'') is included. --- diff --git a/etc/Makefile.in b/etc/Makefile.in index fd00e0d..aa0aa25 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -32,7 +32,7 @@ STATIC_FILES = components digestcomps distcomps forwcomps \ replcomps replgroupcomps scan.MMDDYY scan.YYYYMMDD \ scan.nmh scan.mailx scan.nomime scan.size scan.time \ scan.timely scan.unseen scan.meillo scan.default \ - mhn.defaults + mhn.defaults repllistcomps # ========= DEPENDENCIES FOR BUILDING ========== diff --git a/etc/repllistcomps b/etc/repllistcomps new file mode 100644 index 0000000..24db8d6 --- /dev/null +++ b/etc/repllistcomps @@ -0,0 +1,57 @@ +%; repllistcomps +%; +%; form (components) file for mailing list replies +%; +%; Check the following headers to create reply addresses. +%; +%; To: List-Post +%; +%; OR +%; +%; To: Mail-Followup-To +%; +%; OR +%; +%; To: Mail-Reply-To (or) +%; Reply-To (or) +%; From (or) +%; Sender (or) +%; Return-Path +%; +%; AND +%; +%; Cc: To (and) +%; Cc (and) +%; personal address +%; +%(lit)%(formataddr(unmailto{mail-followup-to}))\ +%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n\ +%|\ +%(lit)%(formataddr{mail-followup-to})\ +%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n\ +%|\ +%(lit)%(formataddr %<{mail-reply-to}%?{reply-to}%?{from}%?{sender}%?{return-path}%>)\ +%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n%>\ +%(lit)%(formataddr{to})%(formataddr{cc})%(formataddr(me))\ +%<(nonnull)%(void(width))%(void(decode))%(putaddr Cc: )\n%>\ +%>\ +%>\ +%; +Fcc: +sent +Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%> +%; +%; Make References: and In-reply-to: fields for threading. +%; Use (trim) to eat trailing whitespace. +%; +%<{message-id}In-reply-to: %{message-id}\n%>\ +%<{message-id}References: \ +%<{references}%(trim{references})%(putstr) %>\ +%(trim{message-id})%(putstr)\n%>\ +Comments: In-reply-to \ +%<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\ +%(putstr(trim(decode)))\n\ + message dated "%<(nodate{date})%{date}%|%(tws{date})%>." +-------- +[%4(year{date})-%02(mon{date})-%02(mday{date}) \ +%02(hour{date}):%02(min{date})] %(decode{from}) +> diff --git a/h/fmt_compile.h b/h/fmt_compile.h index a84efae..f034c6c 100644 --- a/h/fmt_compile.h +++ b/h/fmt_compile.h @@ -101,4 +101,6 @@ #define FT_V_MATCH 87 /* V = 1 if "str" contains literal */ #define FT_V_AMATCH 88 /* V = 1 if "str" starts with literal */ +#define FT_LS_UNMAILTO 89 /* remove "mailto:" */ + #define IF_FUNCS FT_S_NULL /* start of "if" functions */ diff --git a/man/mh-format.man5 b/man/mh-format.man5 index f450012..703e633 100644 --- a/man/mh-format.man5 +++ b/man/mh-format.man5 @@ -291,6 +291,7 @@ compval comp integer Set \fInum\fR to `\fBatoi\fR(\fIcomp\fR\^)' decode expr string decode \fIstr\fR as RFC-2047 (MIME-encoded) component and print it unquote expr string remove RFC-2822 quotes from \fIstr\fR +unmailto expr string remove `mailto:' and < > from \fIstr\fR trim expr trim trailing white-space from \fIstr\fR putstr expr print \fIstr\fR putstrf expr print \fIstr\fR in a fixed width diff --git a/sbr/fmt_compile.c b/sbr/fmt_compile.c index 566f620..2b32e71 100644 --- a/sbr/fmt_compile.c +++ b/sbr/fmt_compile.c @@ -203,6 +203,7 @@ static struct ftable functable[] = { { "mymbox", TF_COMP, FT_LV_COMPFLAG, FT_MYMBOX, TFL_PUTN }, { "unquote", TF_EXPR, FT_LS_UNQUOTE, 0, TFL_PUTS}, + { "unmailto", TF_EXPR, FT_LS_UNMAILTO, 0, TFL_PUTS}, { NULL, 0, 0, 0, 0 } }; diff --git a/sbr/fmt_scan.c b/sbr/fmt_scan.c index 6cfc176..9ad7b8a 100644 --- a/sbr/fmt_scan.c +++ b/sbr/fmt_scan.c @@ -846,6 +846,20 @@ fmt_scan(struct format *format, char *scanl, int width, int *dat) } break; + case FT_LS_UNMAILTO: + if (!str) { + break; + } + str = trim(str); + if (*str == '<' && str[strlen(str)-1] == '>') { + str++; + str[strlen(str)-1] = '\0'; + } + if (strncmp("mailto:", str, 7)==0) { + str += 7; + } + break; + } fmt++; } diff --git a/uip/fmtdump.c b/uip/fmtdump.c index a91333b..d75849b 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -303,6 +303,9 @@ dumpone(struct format *fmt) case FT_LV_DAT: printf(", value dat[%d]", fmt->f_value); break; + + case FT_LS_UNMAILTO: + break; } putchar('\n'); } @@ -420,6 +423,7 @@ f_typestr(int t) case FT_V_GT: return("V_GT"); case FT_V_MATCH: return("V_MATCH"); case FT_V_AMATCH: return("V_AMATCH"); + case FT_LS_UNMAILTO: return("LS_UNMAILTO"); default: printf(buf, "/* ??? #%d */", t); return(buf);