Non-ASCII tags are corrupted on IMAP servers due to lowercased MUTF-7 encoding
Categories
(MailNews Core :: Networking: IMAP, defect)
Tracking
(Not tracked)
People
(Reporter: public-mail, Assigned: welpy-cw)
References
(Blocks 2 open bugs)
Details
Attachments
(2 external files)
Comment 2•13 years ago
|
||
Comment 3•13 years ago
|
||
Updated•13 years ago
|
Comment 5•13 years ago
|
||
Comment 6•13 years ago
|
||
| Reporter | ||
Comment 7•13 years ago
|
||
Comment 8•11 years ago
|
||
Comment 9•7 years ago
|
||
Note: I worked with another Russian to solve issues with his tags (in Russian) and there was no complaints that they appear as lower-case ASCII. But maybe this is a different issue, not sure.
Updated•4 years ago
|
Comment 10•4 years ago
|
||
Is there any update on this? I have the same problem. I try to add the Tag called â which in UTF7 modified would be &AOI- but Thunderbird sends it via IMAP as &aoi- which is first of all invalid because the last 2 bits resulted from the base64 modified encoding are not 00, but 10 (see reference from rfc below), but most importantly, ignoring that, this character would translate into utf8 to 檈
UTF7 is case sensitive. Thunderbird should not send invalid UTF7 via IMAP. I would rather have it not expose non-ascii tags or even not expose tags at all.
From RFC-2151: UTF-7
Instead, when encoding, zero bits are
added to pad to a Base64 character boundary. When decoding, any
bits at the end of the Modified Base64 sequence that do not
constitute a complete 16-bit Unicode character are discarded. If
such discarded bits are non-zero the sequence is ill-formed.
| Assignee | ||
Updated•5 months ago
|
| Assignee | ||
Comment 11•5 months ago
|
||
Historically, custom tag names were converted to IMAP keywords using a Modified UTF-7
encoder, followed immediately by a lowercase conversion. Because MUTF-7 relies on
case-sensitive Base64, the forced lowercasing irreversibly corrupted the string for
any non-ASCII tags (e.g., Cyrillic, Kanji), leading to garbled output on other
clients (Bug 650623).
Furthermore, MUTF-7 is strictly defined for folder names, not flags. RFC 3501
mandates that IMAP flags must be case-insensitive, 7-bit ASCII atoms. The legacy
MUTF-7 conversion often produced the shift character '&', which is an atom-special
that crashes strict IMAP parsers (like iCloud) during -FLAGS commands.
This patch completely modernizes Tag Key generation, prioritizing both protocol
safety and lossless data preservation for international users:
- Drops the broken MUTF-7 conversion entirely.
- Introduces a custom "Modified Quoted-Printable" hex encoding (
=XX) for non-ASCII
characters, spaces, and IMAP atom-specials. This ensures the resulting key is
a 100% compliant, server-safe IMAP atom while retaining the exact UTF-8 byte
sequence for lossless reverse-decoding. - Explicitly escapes the
=character to prevent decoding collisions. - Replaces the legacy Netscape-era
A,AA,AAAdeduplication suffix loop
with readable integer suffixes (_1,_2) to gracefully handle naming
collisions.
Updated•5 months ago
|
| Assignee | ||
Comment 12•5 months ago
|
||
The nsMsgTagService::GetSelectorForKey function contained an obsolete
comment referencing the legacy MUTF-7 tag encoding, as well as a Mozilla
String Guide violation where SetCapacity() was immediately neutralized by
a subsequent Assign() call.
This commit refactors the CSS selector generator:
- Replaces the unnecessary double-pass loop with a clean, single-pass build.
- Adopts
mozilla::IsAsciiAlphanumericandBeginReading()/EndReading()
for standard, safe XPCOM string iteration.
| Assignee | ||
Comment 14•5 months ago
•
|
||
(In reply to Hartmut Welpmann [:welpy-cw] from comment #11)
- Introduces a custom "Modified Quoted-Printable" hex encoding (
=XX) for non-ASCII
characters, spaces, and IMAP atom-specials. This ensures the resulting key is
a 100% compliant, server-safe IMAP atom while retaining the exact UTF-8 byte
sequence for lossless reverse-decoding.
This might be a useful change considering a possible implementation for bug 731143.
| Assignee | ||
Updated•5 months ago
|
Comment 15•5 months ago
|
||
Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/7c5287edb0db
Rewrite IMAP tag key generation to produce valid atoms and drop broken MUTF-7. r=BenC
https://hg.mozilla.org/comm-central/rev/e5354e11ec68
Modernize CSS selector generation for message tags. r=mkmelin
| Assignee | ||
Updated•1 month ago
|
Description
•