Hello,
After upgrading from Dovecot 2.3.21 to 2.4.2 (Ubuntu 26.04 package 1:2.4.2+dfsg1-3ubuntu2.1), Apple Mail on macOS started showing non-ASCII attachment names as mojibake (for example "АД.docx" is displayed as "ÐÐ.docx", i.e. UTF-8 bytes read as Latin-1). The messages themselves are standards-compliant and identical on disk; only the IMAP BODYSTRUCTURE changed.
Message part headers (generated by Symfony Mailer):
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; name="=?utf-8?Q?=D0=90=D0=94=2Edocx?=" Content-Disposition: attachment; name*=utf-8''%D0%90%D0%94.docx; filename*=utf-8''%D0%90%D0%94.docx
Dovecot 2.3.21 returned the extended parameter as-is, ASCII with the charset label:
("attachment" ("name*" "utf-8''%D0%90%D0%94.docx" "filename*" "utf-8''%D0%90%D0%94.docx"))
Dovecot 2.4.2 decodes it and returns raw 8-bit UTF-8 under the plain key, with no charset information:
("attachment" ("name" {9} <D0 90 D0 94>.docx "filename" {9} <D0 90 D0 94>.docx))
The client (UTF8=ACCEPT not enabled) has no way to know the charset of these bytes, and Apple Mail interprets them as Latin-1. After Mailbox -> Rebuild in Apple Mail, every such message shows broken names.
As far as I can tell from the sources, this comes from commit a8e2f8cbe "lib-mail: Fix & unify RFC2231 parsing behavior" (2.4.1), which made rfc2231_parse() decode extended values via rfc2231_decode_charset_value() and return them under the non-star key. imap-bodystructure.c still writes the value as a literal, so 8-bit data reaches non-UTF8=ACCEPT clients. The behaviour seems unchanged up to 2.4.5, and I could not find a setting to restore the previous output.
Was this change in IMAP output intentional? For clients that have not enabled UTF8=ACCEPT, would it be possible to keep the RFC 2231 form in BODYSTRUCTURE (as in 2.3), or to re-encode the decoded value (e.g. as an RFC 2047 encoded-word) instead of sending raw 8-bit?
I can provide doveconf -n output or a test message if needed.
Thank you, Aleksandr