From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mlmmj.mlmmj.org (mlmmj.mlmmj.org [194.233.166.186]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A629606A69D for ; Mon, 30 Nov 2026 13:59:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key, unprotected) header.d=eden.one header.i=@eden.one header.a=rsa-sha256 header.s=mail header.b=WkcBBtCs Received: from localhost ([127.0.0.1]:57076 helo=mlmmj.mlmmj.org) by mlmmj.mlmmj.org with esmtp (Exim 4.96) (envelope-from ) id 1xY1GQ-005iBQ-24 for mlmmj@archiver.kernel.org; Mon, 30 Nov 2026 13:17:50 +0000 Received: from mail.eden.one ([46.224.199.17]:51747) by mlmmj.mlmmj.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xY1GJ-005iAf-0b for mlmmj@mlmmj.org; Mon, 30 Nov 2026 13:17:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eden.one; s=mail; t=1796044751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OOA+ggFTznhy1az1V03ClAPG+3v3ZpHMN3FJmhJE+5U=; b=WkcBBtCsLNZ905B0K4jwfkCUN76DS58tUtW0bITfKEsBjdRBfHIBQkxSpUYzwQrfPYb22F txzW50dD6kzqUm9+bmJKBLRmLGxHvGYIK5xAkLzGP9lsa01uOAYm4mzrKqFlXbHhqaOmN5 mHe1W7O7AXwRYksutDfIT7MnM5VT0G4qvx2xwsQZ24+GMHiAgbG8d2iwV6UUwr4Tg1ZNq6 Nqx/HlH6Sz+K3iBMG/jH7vzf2kGwEQQthwRqAW7OaakGOoMsj95URKG+NNRwYM2x79MXlj jTicG+V1oHzK2iNB9Y7MBI7m3htnUO6Cee6ylWoud97T/n1eQ9KqZZulvzN1/QqROVECpF Q6djYd8ywVL5gphgq1aqhpSG0DXN2klSLtZ//JTmC4NIbPhx70S2UHfZ9whi3JGHT5/eaB F2Cl1Btnv+fd8daH8DantKPMN9IhPu5To3HwMuMmdiJK6cloOfaAHXZF+2YDqUAcltnZBo F3kJJz1A+fp8mntaZsC4HNzWUuWJw9Ccc8eeD8T5ri4KFxlSzwqkCYa04jsJ9QX23LKLpZ XOC2sAgsanwjjWyzKDIHCrEMB50aSmCK8wBtpfEYQh/v87VlGnJ+3QPsHGzO4dOvY+0F2B cac9n/uL6p3aeFnstm+DCJB8OjSl4bXyDKE4z3Pi8sR+GgDRDloXs= X-Rspamd-Server: mail.eden.one X-Rspamd-Action: no action X-Spamd-Bar: ------- X-Spamd-Result: default: False [-7.93 / 12.00]; OWN_MAIL(-5.00)[]; BAYES_HAM(-2.93)[99.69%]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; ARC_NA(0.00)[]; ASN(0.00)[asn:680, ipnet:195.37.0.0/16, country:DE]; RCVD_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_SIGNED(0.00)[eden.one:s=mail]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; LOCAL_OUTBOUND(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; MISSING_XM_UA(0.00)[] X-Rspamd-Queue-Id: f7166677 Authentication-Results: mail.eden.one; auth=pass smtp.mailfrom=tech@eden.one Received: by mail.eden.one (OpenSMTPD) with ESMTPSA id f7166677 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 30 Nov 2026 14:19:11 +0100 (CET) Date: Mon, 30 Nov 2026 14:19:11 +0100 From: Jan Eden To: mlmmj@mlmmj.org Subject: Re: Re: [PATCH] Support display name substitution in customheaders Message-ID: References: <83Su95j/WN8QKsJA6dPhlkwgNx6bkcF5@etherlight.link> <362a66a2c2eb55ecd94e6cc97bcf36ae035867d5@nours.eu> <64E005BC-B493-4788-A4E0-3F2DF4ABF23E@nours.eu> List-Id: List-Help: List-Post: List-Subscribe: Sender: X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <64E005BC-B493-4788-A4E0-3F2DF4ABF23E@nours.eu> X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi, I just tested the $disarmedfrom$ variable which resulted in the following From header: From: =?utf-8?q?Jan_Eden_=28jaed=3Dexample.com=29?= via Testing This was rewarded with a penalty (FROM_EXCESS_QP(1.20)[];) by Rspamd. Is there any way around this to keep the spam score of my list messages in check? - Jan On 2026-03-29 16:13, Baptiste Daroussin wrote: > I have the code for rfc2047 decoding in my mlmmj archiver, I can reuse it (it only depends on iconv) but it makes it a more complicated task, so will be for 2.1 > > Best regards, > Bapt > > Le 29 mars 2026 15:32:36 GMT+02:00, "Jona Müller" a écrit : > >I would also +1 RFC2047 as we have many people with non-ascii names (Myself > >included). From experience, this can be quite a pain to support correctly as > >around the world people still use a lot of encodings other than UTF-8. The most > >common in my experience are: > > > > ISO-8859-1 (Western europe latin1) > > ISO-2022-JP (non-UTF-8 Japanese) > > > >A quick hack would be to throw out any encoded words (=?UTF-8?...) and just use > >the local part (address) in that case. > > > >The options to do it correctly would be in my opinion: > > > > 1. Do it by hand and suffer > > 2. Introduce some large dependency that handles it > > > >I'm against 2, and I think having few dependencies is one of mlmmj's strengths. > > > >Tests would be very nice, I agree. > > > >Cheers, > >-jm > >================================ > >Independend GmbH > > > >Jona.Mueller@independend.ch > >+49 6832 265556 > > > >http://ind.me > > > >On Sun, Mar 29, 2026 at 02:33:28PM +0200, Baptiste Daroussin wrote: > >> after a quick read of the match, the extracted display name is not sanitized, it should probably be. > >> > >> the parser at quick glance seems fragile, what happen if the display name is "Doe, John" > >> > >> Would be nice to get a bunch of tests to make sure everything works as expected. > >> > >> also I don t think rfc 2047 is handled. > >> > >> Best regards, > >> bapt > >> > >> Le 29 mars 2026 10:13:54 GMT+02:00, Baptiste Daroussin a écrit : > >> >Thank you, I will have a look at it asap, and see integrate it if possible in 2.0.0 which I intend to release soon > >> > > >> >Best regards, > >> >Bapt > >> > > >> >March 27, 2026 at 7:14 PM, "Lumin Etherlight" wrote: > >> >> > >> >> Allow substitution of the variable $postername$ for > >> >> the display name of the user. The display name is > >> >> extracted from the sender's From: header. If a name > >> >> is not found, then this variable is substituted for > >> >> user's address, i.e. the same value as $posteraddr$. > >> >> Proper handling of comments, and quoted strings, in > >> >> the From: address is also included. > >> >> > >> >> This allows the following `customheaders' use-case: > >> >> > >> >> From: $postername$ via Project-List > >> >> > >> >> Which would render, for example, as: > >> >> > >> >> From: John Doe via Project-List > >> >> > >> >> For the user: > >> >> > >> >> John Doe . > >> >> --- > >> >> AUTHORS | 1 + > >> >> include/find_email_adr.h | 1 + > >> >> include/wrappers.h | 2 +- > >> >> src/do_all_the_voodoo_here.c | 22 ++++++++++++--- > >> >> src/dumpfd2fd.c | 14 +++++++++- > >> >> src/find_email_adr.c | 52 ++++++++++++++++++++++++++++++++++++ > >> >> 6 files changed, 86 insertions(+), 6 deletions(-) > >> >> > >> >> diff --git a/AUTHORS b/AUTHORS > >> >> index be21ced..9d9b7df 100644 > >> >> --- a/AUTHORS > >> >> +++ b/AUTHORS > >> >> @@ -1,3 +1,4 @@ > >> >> Mads Martin Joergensen > >> >> Morten K. Poulsen > >> >> Ben Schmidt > >> >> +Lumin Etherlight > >> >> diff --git a/include/find_email_adr.h b/include/find_email_adr.h > >> >> index e5da89b..707fdd6 100644 > >> >> --- a/include/find_email_adr.h > >> >> +++ b/include/find_email_adr.h > >> >> @@ -27,5 +27,6 @@ > >> >> #include > >> >> > >> >> strlist *find_email_adr(const char *str, strlist *retval); > >> >> +char *find_display_name(char *name); > >> >> > >> >> #endif /* FIND_EMAIL_ADR_H */ > >> >> diff --git a/include/wrappers.h b/include/wrappers.h > >> >> index 2953bd2..5a2c144 100644 > >> >> --- a/include/wrappers.h > >> >> +++ b/include/wrappers.h > >> >> @@ -31,6 +31,6 @@ ssize_t readn(int fd, void *vptr, size_t n); > >> >> int random_int(void); > >> >> int dumpfd2fd(int infd, int outfd); > >> >> int copy_file(int infd, int outfd, size_t bufsiz); > >> >> -int process_headers(int infd, FILE *outf, const char *from); > >> >> +int process_headers(int infd, FILE *outf, const char *from, const char *name); > >> >> > >> >> #endif /* WRAPPERS_H */ > >> >> diff --git a/src/do_all_the_voodoo_here.c b/src/do_all_the_voodoo_here.c > >> >> index 13aeb74..14214a8 100644 > >> >> --- a/src/do_all_the_voodoo_here.c > >> >> +++ b/src/do_all_the_voodoo_here.c > >> >> @@ -80,6 +80,7 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> char *hdrline, *unfolded, *unqp; > >> >> strlist allunfoldeds = tll_init(); > >> >> char *posteraddr = NULL; > >> >> + char *postername = NULL; > >> >> bool hdrsadded = false; > >> >> bool subject_present = false; > >> >> int dupfd = dup(infd); > >> >> @@ -111,9 +112,16 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> if(hdrfd >= 0) { > >> >> strlist fromemails = tll_init(); > >> >> if ( readhdrs[0].valuecount == 1 ) { > >> >> - find_email_adr(readhdrs[0].values[0], &fromemails); > >> >> - if (tll_length(fromemails) > 0) > >> >> + find_email_adr(readhdrs[0].values[0], &fromemails); > >> >> + if (tll_length(fromemails) > 0) { > >> >> posteraddr = xstrdup(tll_front(fromemails)); > >> >> + postername = find_display_name(readhdrs[0].values[0]); > >> >> + if (!postername) { > >> >> + postername = posteraddr ? > >> >> + xstrdup(posteraddr) : > >> >> + xcalloc(1, 1); > >> >> + } > >> >> + } > >> >> } > >> >> tll_free_and_free(fromemails, free); > >> >> } > >> >> @@ -129,12 +137,13 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> if(!hdrsadded && > >> >> ( strncasecmp(hdrline, "mime", 4) == 0)) { > >> >> if(hdrfd >= 0) { > >> >> - if(process_headers(hdrfd,outf,posteraddr ? posteraddr : "") < 0) { > >> >> + if(process_headers(hdrfd,outf,posteraddr ? posteraddr : "", postername ) < 0) { > >> >> log_error(LOG_ARGS, "Could not " > >> >> "add extra headers"); > >> >> free(unfolded); > >> >> tll_free_and_free(allunfoldeds, free); > >> >> free(posteraddr); > >> >> + free(postername); > >> >> fclose(outf); > >> >> fclose(f); > >> >> return -1; > >> >> @@ -174,11 +183,12 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> > >> >> if(!hdrsadded ) { > >> >> if(hdrfd >= 0) { > >> >> - if(process_headers(hdrfd,outf,posteraddr ? posteraddr : "") < 0) { > >> >> + if(process_headers(hdrfd,outf,posteraddr ? posteraddr : "", postername) < 0) { > >> >> log_error(LOG_ARGS, "Could not " > >> >> "add extra headers"); > >> >> tll_free_and_free(allunfoldeds, free); > >> >> free(posteraddr); > >> >> + free(postername); > >> >> fclose(outf); > >> >> fclose(f); > >> >> return -1; > >> >> @@ -195,6 +205,7 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> tll_free_and_free(allunfoldeds, free); > >> >> log_error(LOG_ARGS, "Error writing hdrs."); > >> >> free(posteraddr); > >> >> + free(postername); > >> >> fclose(outf); > >> >> fclose(f); > >> >> return -1; > >> >> @@ -209,6 +220,7 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> if(dumpfd2fd(infd, outfd) < 0) { > >> >> log_error(LOG_ARGS, "Error when dumping rest of mail"); > >> >> free(posteraddr); > >> >> + free(postername); > >> >> fclose(f); > >> >> return -1; > >> >> } > >> >> @@ -219,11 +231,13 @@ int do_all_the_voodoo_here(int infd, int outfd, int hdrfd, int footfd, > >> >> if(dumpfd2fd(footfd, outfd) < 0) { > >> >> log_error(LOG_ARGS, "Error when adding footer"); > >> >> free(posteraddr); > >> >> + free(postername); > >> >> return -1; > >> >> } > >> >> > >> >> fsync(outfd); > >> >> > >> >> free(posteraddr); > >> >> + free(postername); > >> >> return 0; > >> >> } > >> >> diff --git a/src/dumpfd2fd.c b/src/dumpfd2fd.c > >> >> index 674e2b0..431bac2 100644 > >> >> --- a/src/dumpfd2fd.c > >> >> +++ b/src/dumpfd2fd.c > >> >> @@ -84,7 +84,7 @@ int dumpfd2fd(int from, int to) > >> >> return (r); > >> >> } > >> >> > >> >> -int process_headers(int infd, FILE *outf, const char *from) > >> >> +int process_headers(int infd, FILE *outf, const char *from, const char *name) > >> >> { > >> >> char *line = NULL, *p, *to_be_subst, *new_line; > >> >> size_t linecap = 0; > >> >> @@ -120,6 +120,18 @@ int process_headers(int infd, FILE *outf, const char *from) > >> >> return -1; > >> >> } > >> >> free(new_line); > >> >> + } else if ((to_be_subst = strstr(p, "$postername$")) != NULL) { > >> >> + *to_be_subst = '\0'; > >> >> + to_be_subst += 12; > >> >> + xasprintf(&new_line, "%s%s%s", p, name, to_be_subst); > >> >> + if (fprintf(outf, "%s", new_line) < 0) { > >> >> + log_error(LOG_ARGS, "Could not write headers"); > >> >> + free(new_line); > >> >> + free(line); > >> >> + fclose(f); > >> >> + return -1; > >> >> + } > >> >> + free(new_line); > >> >> } else { > >> >> if (fprintf(outf, "%s", p) < 0) { > >> >> log_error(LOG_ARGS, "Could not write headers"); > >> >> diff --git a/src/find_email_adr.c b/src/find_email_adr.c > >> >> index 0830098..77b7cef 100644 > >> >> --- a/src/find_email_adr.c > >> >> +++ b/src/find_email_adr.c > >> >> @@ -239,3 +239,55 @@ oncemore: > >> >> > >> >> return retstruct; > >> >> } > >> >> + > >> >> +/* ---------------------------------------------------------------------------*\ > >> >> + * Extract the display name of the first user, > >> >> + * removing comments, for example: > >> >> + * > >> >> + * for the input string: > >> >> + * "John (Amazing) Smith" , > >> >> + * "Jane Doe" >> >> + * > >> >> + * returns: "John Smith" > >> >> +\* ---------------------------------------------------------------------------*/ > >> >> +char * > >> >> +find_display_name (char *name) > >> >> +{ > >> >> + char *p, *nbuf, c; > >> >> + int nbuf_len, saw_angled_brackets; > >> >> + > >> >> + if (!name) return NULL; > >> >> + nbuf = xmalloc(strlen(name)); > >> >> + saw_angled_brackets = 0; > >> >> + nbuf_len = 0; > >> >> + > >> >> + for (p = name; (c = *p) != '\0' && isspace(c); p++); > >> >> + while ((c = *p++) != '\0') { > >> >> + switch (c) { > >> >> + case '(': > >> >> + p = skip_comment(p); > >> >> + /* -------------------------------*\ > >> >> + * Copy at most one space in place > >> >> + * of the comment. Don't copy any > >> >> + * whitespace if we are still at > >> >> + * the beginning of the string. > >> >> + */ > >> >> + if (nbuf_len > 0 && isspace(*p) && > >> >> + !isspace(nbuf[nbuf_len-1])) { > >> >> + nbuf[nbuf_len++] = *p++; > >> >> + } > >> >> + while(isspace(*p)) p++; > >> >> + /* -------------------------------*/ > >> >> + break; > >> >> + case '<': saw_angled_brackets = 1; goto finished; > >> >> + case ',': goto finished; > >> >> + default: nbuf[nbuf_len++] = c; break; > >> >> + } > >> >> + } > >> >> + > >> >> + finished: > >> >> + if (!saw_angled_brackets || nbuf_len == 0) { free(nbuf); return NULL; } > >> >> + for (p--, p--; (c = *p) && isspace(c); p--, nbuf_len--); > >> >> + nbuf[nbuf_len++] = '\0'; > >> >> + return nbuf; > >> >> +} > >> >> -- > >> >> 2.46.4