Re: [PATCH 1/2] Rearrange and consolidate final encoding steps when sending.
"Kevin J. McCarthy" <[email protected]> Sat, 16 May 2026 06:30:11 +0800
| Newsgroups | gmane.mail.mutt.devel |
|---|---|
| Message-ID | <ageec1a_Z3Yf1TGd@qinghai> |
On Fri, May 15, 2026 at 03:08:51PM +0200, Alejandro Colomar via Mutt-dev wrote:
>On 2026-05-15T20:28:08+0800, Kevin J. McCarthy wrote:
>> mutt_encode_descriptions(sctx->msg->content, 1);
>> + mutt_prepare_envelope(sctx->msg->env, 1);
>> + if (mutt_env_to_intl(sctx->msg->env, &tag, &err))
>> + {
>> + mutt_error(_("Bad IDN in \"%s\": '%s'"), tag, err);
>> + FREE(&err);
>> + if (!(sctx->flags & SENDBATCH))
>> + {
>> + sctx->msg->content = mutt_remove_multipart_mixed(sctx->msg->content);
>> + sctx->msg->content = mutt_remove_multipart_alternative(sctx->msg->content);
>> + decode_descriptions(sctx->msg->content);
>> + mutt_unprepare_envelope(sctx->msg->env);
>> + goto main_loop;
>> + }
>> + else
>> + goto cleanup;
>
>I see why you've done it this way: minimizing changes to existing code.
>However, I suggest rewriting this to invert the logic:
>
> if (sctx->flags & SENDBATCH)
> goto cleanup;
>
> sctx->msg->content = mutt_remove_multipart_mixed(sctx->msg->content);
> sctx->msg->content = mutt_remove_multipart_alternative(sctx->msg->content);
> decode_descriptions(sctx->msg->content);
> mutt_unprepare_envelope(sctx->msg->env);
> goto main_loop;
Hi Alex,
Okay, I'll do a follow up error handling cleanup patch.
>> @@ -2523,12 +2524,11 @@ main_loop:
>> if ((crypt_get_keys(sctx->msg, &pgpkeylist, 0) == -1) ||
>> mutt_protect(sctx, pgpkeylist, 0) == -1)
>> {
>> + FREE(&pgpkeylist);
>> sctx->msg->content = mutt_remove_multipart_mixed(sctx->msg->content);
>> sctx->msg->content = mutt_remove_multipart_alternative(sctx->msg->content);
>> -
>> - FREE(&pgpkeylist);
>> -
>
>The movement of this FREE() seems no obvious from the commit message.
>Is it intrinsic to this patch?
Only from the standpoint that I was also doing a little bit of cleanup
:D. I moved the pgpkeylist free to the beginning to match the order in
the error handling blocks below and above.
The important part was the introduction of the call to
mutt_unprepare_envelope():
>> decode_descriptions(sctx->msg->content);
>> + mutt_unprepare_envelope(sctx->msg->env);
>> goto main_loop;
--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C 5308 ADEF 7684 8031 6BDA
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmoHnnMACgkQre92hIAx a9ra2A//bOPjQi5Lr4C0oxrkG+AR94lmZmjHy8F32OYVkzV071yYaC/LWRPBgv3O 2Ex5brZ4kyAcXJAXwyaEfqrLxPQOnyoH4AsYJ9NFztdsl/LzdC47u5/+iV5/t6aF nmXtYvgISFhWEd8X133CxZBw6ne1QBEisocxbvyKF3DuSU8V1IhJrRmjCg6I1Sl8 fB70AUvhz3IkxqixoUuAlQa5U9x96W6lCh99NmLYeF4X7oqGtC3OyL5zxL71/w83 wcRhjd6FEgypkYgnOGWXSwUcmkOKH4QPDl+n8q8NRGW8cX8xDf+NbS226rCPmHPe OkgvtE3CaIm2tYKQyoQNWK73apvfUSCNJqygciA2WSlfASMvD2wrKjlQjbX0Bf8g r+hDVMMLLMJH63MKwgUBzdpi1beqXxgRxeYkRhASHQLwK0HPl/3uAERj8H1hGlqM tG1XGJz8ps1igjPk1RVU0rjxgAK5Mjyq2qFzuMg3SclvdtkUAlFMXfsJxiRqEGSd lO72dJOVJ6SCIFaRv0Cn/f0zijY2Fa3yFjVh1mgSt9yZ287KrMIf2zCy3GwaJ5aX gN5/r+aBuqA61GTXMXm33UyQ01XnX0JCOgJ1tRf2pSAUsEQ8Om/r68P8Arhulk/c qC19IkI/4OqGz2M6ClVcE0mf+0ohFZ6sIabobI363a3bQsof0kQ= =RUKP -----END PGP SIGNATURE-----