icloud imap access using QRESYNC and CONDSTORE

I'm the IMAP maintainer for Mozilla Thunderbird. I've been looking into adding QRESYNC imap extension to Thunderbird which currently only supports CONDSTORE extension.

The icloud server returns these in its capabilities response: CONDSTORE ENABLE QRESYNC indicating complete support for enabling CONDSTORE and QRESYNC.

But when I try to enable them, I get no "ENABLED" untagged response as required by imap ENABLE rfc:

Tbird sends: 33 ENABLE CONDSTORE QRESYNC UTF8=ACCEPT
icloud sends: 33 OK ENABLE completed

The correct imap ENABLED response is like this:

Tbird sends: 33 ENABLE CONDSTORE QRESYNC UTF8=ACCEPT
icloud sends: * ENABLED CONDSTORE QRESYNC
icloud sends: 33 OK ENABLE completed

Since icloud doesn't support the UTF8=ACCEPT imap extension, it should just be excluded from the untagged ENABLED response. Several other imap servers I've tested (Dovecot, Cyrus and Zimbra) respond correctly when Thunderbird attempts the ENABLE but icloud responds in a non-standard manner.

There are other problems too with the icloud response to imap SELECT with the QRESYNC parameter in that it produces an imap FETCH response for all messages in the folder with a sequence number of minus 1 (sequence numbers are supposed to be positive, 1 to number of messages in folder, never negative).

Note: This seems to require a tag. Couldn't find one relevant to my question so just picked one with "icloud" in name.

I don't know if the CONDSTORE/QRESYNC issue has been fix or if maybe I'm connecting now to a different icloud imap server, but the problem seems to be resolved!

I didn't note the version of the original server when I saw the problem, but the revision returned by imap ID is now "2204B190" and seems to work correctly. I still need to do more testing to make completely sure.

There is still one issue that is not really CS/QR specific. I see this:

38 UID fetch 31:* (FLAGS)
38 OK FETCH completed (took 6 ms)

According to RFC 3501, this should return the flags for the last UID message instead of returning nothing. See https://datatracker.ietf.org/doc/html/rfc3501#section-6.4.8:

Also note that a UID range of 559:* always includes the
UID of the last message in the mailbox, even if 559 is
higher than any assigned UID value.

In case someone who works on icloud imap is reading this, there is one more thing I've noticed. The imap LANGUAGE command is advertised as a capability but it always fails like this:

27 LANGUAGE en-US
27 BAD Parse Error (took 0 ms)

I've tried various other language code strings and even quoted the language code string and it makes no difference.

icloud imap access using QRESYNC and CONDSTORE
 
 
Q