Skip to content

Conversation

arnt
Copy link
Contributor

@arnt arnt commented Jan 24, 2025

5530 (ENABLE) lets a client tell the server which extensions it would like to use, and lets the server tell the client which extensions is has enabled. Most IMAP extensions don't need to be enabled, but UTF8=ACCEPT does.

6855 (UTF8=ACCEPT) requires three things of clients:

  1. The client uses ENABLE (added with tests)
  2. The client accepts UTF8 strings (worked already, this adds testing)
  3. The client cannot use certain SEARCH syntax (tb already did not)

6855 also allows some optimisations that this change does not contain:

  1. A client can send UTF8 quoted-strings instead of some literals
  2. A client can send UTF8 folder names instead of mUTF7

This change doesn't do either of those, because they add complexity (and unit tests) but no functionality. Some IMAP commands become three or seven or even ten bytes smaller. Who cares?

RFC 6855 differs modestly from its replacement, currently in the RFC-editor's queue. This implementation sides with the newer RFC when there's any difference.

This commit contains a couple of unit tests that do nothing right now, they merely guard against possible future breakage.

@arnt arnt requested review from cketti and wmontwe as code owners January 24, 2025 16:42
@cketti
Copy link
Collaborator

cketti commented Jan 24, 2025

We need to make sure mailbox names are properly decoded.

My understanding of RFC 6855 is that LIST responses won't use the modified UTF-7 encoding for mailbox names when UTF8=ACCEPT is enabled. Is that correct?

The RFC text reads ambiguous to me (emphasis mine):

The "UTF8=ACCEPT" capability indicates that the server supports the ability to open mailboxes containing internationalized messages with the "SELECT" and "EXAMINE" commands, and the server can provide UTF-8 responses to the "LIST" and "LSUB" commands.

That makes it sound like the server can use mUTF-7 or UTF-8 and the client has to deal with it. However, I don't see how a client could distinguish a mUTF-7 encoded string from a UTF-8-encoded string that happens to also be a valid, non-trivial mUTF-7 encoding.
Example:
"A &- B" when mUTF-7-encoded decodes to "A & B". However, when UTF-8-encoded decodes to "A &- B".

@arnt
Copy link
Contributor Author

arnt commented Jan 24, 2025

Excellent point. I don't think that was raised at all during the work on 653x/685x. I think it warrants a late change to 6855bis... I'll try to make the document conform to the majority of client code.

@wmontwe wmontwe removed the request for review from cketti March 20, 2025 10:39
@arnt arnt requested a review from kewisch as a code owner March 20, 2025 14:19
@arnt
Copy link
Contributor Author

arnt commented Mar 20, 2025

We discussed the proper course of action for RFC 9755 (which was published this week, after a very long auth48 phase, guess why). The general opinion is that if you enable utf8, utf8 is what you get and what you need to send. I updated this PR accordingly.

I have a feeling that I'll need to check a lot of software.

@arnt
Copy link
Contributor Author

arnt commented Mar 27, 2025

I force-pushed again because I forgot to run gradle spotlessApply.

The code looks mostly okay in my eyes, except that I found the testing on COPY/MOVE a little sparse. Some people prefer orthogonal testing, others like a little redundancy. I tried do match your style. Let me know if I missed.

@wmontwe
Copy link
Member

wmontwe commented Mar 28, 2025

@arnt Thanks, I'm not too familiar with the addressed RFCs yet. But from a high level view, it looks good.

We want to avoid adding more Java code to the project and maybe you could convert it? Otherwise just ping me and I'll patch this pull-request.

@arnt
Copy link
Contributor Author

arnt commented Apr 1, 2025

That's about EnabledResponse, right? I converted it and force-pushed now. Hope I got it right, I'm not really fluent in Kotlin. Looks like a really nice language, but I still don't know it well enough to write elegant new code from scratch.

(BTW, while I'll try to install and test properly on-device, I haven't for this force-push. Realistic on-device testing requires the tip of mime4j, plus some SMTP code that I have locally.)

@arnt
Copy link
Contributor Author

arnt commented Apr 2, 2025

The remaining failures are in PGP code, which I didn't touch and don't aspire to fix.

@arnt
Copy link
Contributor Author

arnt commented Apr 10, 2025

Hi,

would you mind reviewing again? I'd really like to get to the testable stage.

@kewisch
Copy link
Member

kewisch commented Apr 10, 2025

Hi @arnt, apologies we're a bit short staffed right now. Wolf is away for a bit, cketti is out, and new Android team member(s) are still onboarding. I'll see what we can do here, but worst case it might have to wait until Wolf is back in May.

@arnt
Copy link
Contributor Author

arnt commented Apr 10, 2025

Makes sense, thanks for explaining.

@wmontwe wmontwe moved this from Backlog to In progress in Thunderbird for Android - Sprints May 7, 2025
@wmontwe wmontwe force-pushed the utf8-accept branch 2 times, most recently from 2db6a43 to 1c1dcf3 Compare May 12, 2025 10:41
5530 (ENABLE) lets a client tell the server which extensions it would like
to use, and lets the server tell the client which extensions is has
enabled. Most IMAP extensions don't need to be enabled, but UTF8=ACCEPT
does.

9755 (UTF8=ACCEPT) requires four things of clients:
1. The client uses ENABLE (added with tests)
2. The client accepts UTF8 strings (worked already, this adds testing)
3. The client cannot use certain SEARCH syntax (tb already did not)
4. The client uses UTF8 for folder names instead of mUTF7

This commit contains a couple of unit tests that do nothing right now,
they merely guard against possible future breakage.
@wmontwe
Copy link
Member

wmontwe commented May 12, 2025

@arnt I patched the pull-request and the failing test.

I guess we need mime4j to be released to progress, right?

@wmontwe wmontwe moved this from In progress to In review in Thunderbird for Android - Sprints May 12, 2025
@arnt
Copy link
Contributor Author

arnt commented May 12, 2025

Thanks. Wonder why that test broke.

I'm a little uncertain. A new mime4j release is necessary for real thing, but as I recall this part of the code (#8772 as opposed to #8770) ought to work without it.

It won't really do anything, of course — mail from my friends at 中国互联网络信息中心.中国 will now be rejected after the IMAP stage instead of by the IMAP stage.

(#8772 is just one part. cketti preferred to change one subsystem at a time, for a progression of states where nothing is broken that worked before, and then finally step to a state where the new functionality is user-visible and usable. That final step needs a new mime4j release.)

@wmontwe
Copy link
Member

wmontwe commented May 12, 2025

@arnt Okay, then this is good to go.

Test test broke as the imap connection now always tries to call enable, but the mock wasn't setup for these additional steps.

Copy link
Member

@wmontwe wmontwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@wmontwe wmontwe merged commit 255e128 into thunderbird:main May 12, 2025
3 checks passed
@thunderbird-botmobile
Copy link
Contributor

Thanks for your contribution! Your pull request has been merged and will be part of Thunderbird 12. We appreciate the time and effort you put into improving Thunderbird. If you haven’t already, you’re welcome to join our Matrix chat for contributors. It’s where we discuss development and help each other out. https://matrix.to/#/#tb-android-dev:mozilla.org
Hope to see you there! 🚀📱🐦

@thunderbird-botmobile thunderbird-botmobile bot added this to the Thunderbird 12 milestone May 12, 2025
@arnt
Copy link
Contributor Author

arnt commented May 12, 2025

Oh great, thanks! What next, SMTP? I'll take me a few days, I have to review a 72-page document and am forcing myself to write no code until the review is done.

arnt added a commit to arnt/thunderbird-android that referenced this pull request May 31, 2025
RFC 6855/9755 permits IMAP servers to send UTF8 in strings such as "this", but
does not ban sending literals such as {4}
this
instead, and some servers do, and thunderbird#8772 did not handle that.

Fixes thunderbird#9212
arnt added a commit to arnt/thunderbird-android that referenced this pull request Jul 18, 2025
RFC 6855/9755 permits IMAP servers to send UTF8 in strings such as "this", but
does not ban sending literals such as {4}
this
instead, and some servers do, and thunderbird#8772 did not handle that.

Fixes thunderbird#9212
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants