Re: [PATCH] Add %F expando to $message_id_format to use from address.

"Kevin J. McCarthy" <[email protected]> Tue, 4 Aug 2026 12:38:46 +0800
Newsgroups gmane.mail.mutt.devel
Message-ID <[email protected]>
--SoGbiZNX1Ifh6D3n
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Aug 03, 2026 at 01:12:46PM +0200, Alejandro Colomar via Mutt-dev wr=
ote:
>> From: "Kevin J. McCarthy" <[email protected]>
>> +static const char *ALLOWED_FROM_CHARS =3D "abcdefghijklmnopqrstuvwxyz"
>> +                                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>> +                                        "1234567890-_.";
>
>I suggest a more generic name for this, which documents the fact that
>this is the POSIX Portable Filename Character Set.  Also, I suggest
>using intermediate character sets that have a well-known name, to make
>it easier to distinguish each character set.
>
>	#define CTYPE_LOWER_C          "abcdefghijklmnopqrstuvwxyz"
>	#define CTYPE_UPPER_C          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>	#define CTYPE_DIGIT_C          "0123456789"
>	#define CTYPE_ALPHA_C          CTYPE_LOWER_C CTYPE_UPPER_C
>	#define CTYPE_ALNUM_C          CTYPE_ALPHA_C CTYPE_DIGIT_C
>	#define CTYPE_PFCHAR_C         CTYPE_ALNUM_C "._-"  // portable filename =
character set

Thanks Alex.  I'll add a pre-patch with this to the series and send it=20
out later today for feedback.

>> +
>> +/* This function is much stricter than RFC5322 specifies, because we al=
so want
>> + * the message-id to be passed in a URL as a path segment or parameter =
without
>> + * needing encoding.
>> + */
>> +static void filter_from_addr(char *from)
>> +{
>> +  int has_at =3D 0;
>> +
>> +  if (!from)
>> +    return;
>> +
>> +  while (*from)
>> +  {
>> +    if (*from =3D=3D '@' && !has_at)
>> +      has_at =3D 1;
>> +    else if (!strchr(ALLOWED_FROM_CHARS, *from))
>
>And then here I suggest adding another API, inspired by isascii(3):
>
>	// isascii_c - is [:ascii:] C-locale
>	#define ispfchar_c(c)  (!streq(strchrnul(CTYPE_PFCHAR_C, c), ""))
>
>	#define streq(s1, s2)  (!strcmp(s1, s2))
>
>To be able to write it as
>
>	else if (!ispfchar_c(*from))

I remember the earlier discussion on mutt-dev about this.  I'm going to=20
hold off on this suggestion, as I remember strchrnul() is not=20
standardized, and the fallback suggestions relied on non-standard ?:=20
operators, etc.

The nul's are explicitly checked for in this case, so I don't think it's=20
worth it to dig into that for this case.  (But of course I'll swap out=20
to use CTYPE_PFCHAR_C)

>> +      *from =3D '_';
>> +    from++;
>> +  }
>> +}
>
>In any case, the above seems okay.

Thanks again!

--=20
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

--SoGbiZNX1Ifh6D3n
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmpxbNYACgkQre92hIAx
a9rHDBAAncNA+9TUpfwK8P1LmhIgVXlZ4XQQq9g5su6Dx9c3F8RqyXG6u+U1sSpk
Ms2W0OnQat2Dp+hvI5ie/56B1zSueE22vxd+cp68bvQxwNQ8irJ77REamqoQqfNw
41uJiWdfa+x8npVowO2+iU87pm/Pz8+77IEePD0x3yjj5mu/XRI06XmdwE49le+o
DYEZJ05dCULF7dK/xD9s8sW8ARkt/u2OEzvpYhdrY1KwMmPbbpYFvWDHeJcTnjfT
hm3kRdzsepthBBCFqPcqET+jOVguSst3Glv1i9f70SUn/oGTHtcsAQDjit4ivxGs
KfgqRBpiBav6Q8YIhhazHSMGH0aGBzavWT+nXg73OlRckExGsKUNewNGm+51fFyJ
TqZR6m3Q5DFWXL4zla1Q+u+q3OfcdCnp+J5wmCiccnCGZgnwDF0Q2TKKVseWc6pr
R3q6WpOwnPPJTekxd+kloC026zWNPWPfqFFNVv0QCQHoVhj2GXzguKEMkLYH5aLR
CveE5pxHkSKJt56lYU2EBHyvjYc7eocjmfa7cIVJ2AL/i23E77h+wPtW2cETW793
JRNk0bV1Iz6rSZlKGzdT/Z2hfWmKjtG/L+yiOwDyNkcTLZHHs7ZO5+mJBIH51V+K
t4tZUdztnJLQkH82kmrR54QVZfeVYqPOMxYETvoK8WHjDQIqcC8=
=V3bR
-----END PGP SIGNATURE-----

--SoGbiZNX1Ifh6D3n--