ImapIncomingServer.trashFolderName getter remains charset-unaware on non-UTF8 IMAP servers
Categories
(Thunderbird :: Account Manager, defect)
Tracking
(Not tracked)
People
(Reporter: ludovic.derouin, Unassigned)
Details
Steps to reproduce
-
Set up an IMAP account hosted on a mail server that uses standard IMAP Modified UTF-7 encoding and does not support the UTF8=ACCEPT extension (RFC 6855) (e.g., standard Dovecot, Cyrus, or Zimbra servers).
-
Configure a customized Trash folder containing non-ASCII/accented characters (e.g., French "Éléments supprimés" or German "Gelöscht"):
mail.server.serverX.trash_folder_name = "Éléments supprimés" (stored as UTF-8)
mail.server.serverX.trash_folder = imap://user@host/&AMk-l&AOk-ments%20supprim&AOk-s (stored as URI with MUTF-7) -
Note that while Bug 1958781 (commit 28ebb8877b66) fixed folder flag retention in nsImapIncomingServer::Discovery, inspect how Thunderbird queries the trash folder name during runtime IMAP operations
-
Query the server.trashFolderName getter (exposed in ImapIncomingServer.sys.mjs / nsIImapIncomingServer) or trigger protocol commands relying on the designated trash folder name.
Actual results
-
The getter is charset-unaware:
server.trashFolderName returns the raw UTF-8 string ("Éléments supprimés") directly from trash_folder_name, without checking if the server supports UTF-8.
Because the server expects Modified UTF-7 (&AMk-l&AOk-ments supprim&AOk-s), issuing commands or performing lookups with raw UTF-8 octets causes protocol mismatches and folder lookup failures. Extensions currently have to monkey-patch ImapIncomingServer.prototype.trashFolderName to enforce MUTF-7 conversion on the wire. -
Divergence between trash_folder (URI) and trash_folder_name (preference):
trash_folder holds percent-encoded MUTF-7, while trash_folder_name holds UTF-8. If an automated configuration tool, policy, or extension extracts the folder name from the URI, trash_folder_name becomes polluted with raw MUTF-7 (&AMk-l...). This breaks the comparison introduced in Bug 1958781 (which explicitly assumes trash_folder_name is stored in UTF-8). -
Incomplete fix in Bug 1958781:
Bug 1958781 only patched the comparison inside nsImapIncomingServer::Discovery. It did not fix the getter contract itself, leaving special folder naming fragile whenever localized non-ASCII folders are used without IMAP SPECIAL-USE (RFC 6154).
Expected results
- server.trashFolderName should adapt to the server's capabilities:
When !GetUtf8AcceptEnabled(), the getter in ImapIncomingServer.sys.mjs (and GetTrashFolderName in nsImapIncomingServer.cpp) should automatically convert the stored UTF-8 string into MUTF-7 before returning it for wire operations:
// In ImapIncomingServer.sys.mjs
get trashFolderName() {
let name = this.getUnicharValue("trash_folder_name") || "Trash";
if (name !== "Trash" && !this.utf8AcceptEnabled && /[^\x00-\x7F]/.test(name)) {
const charsetManager = Cc["@mozilla.org/charset-converter-manager;1"]
.getService(Ci.nsICharsetConverterManager);
return charsetManager.unicodeToMutf7(name);
}
return name;
}
-
Thunderbird should handle non-ASCII folder names seamlessly without requiring extensions to monkey-patch ImapIncomingServer.prototype.trashFolderName.
-
Setting or deriving the trash folder from trash_folder (URI) or trash_folder_name should maintain consistent two-way encoding (UTF-8 in the preference for UI display, MUTF-7 on the wire when talking to legacy IMAP servers).
Comment 1•1 month ago
|
||
This is being fixed in bug 2048831
Description
•