K-9: Use folding to properly handle To/CC/BCC with more than 1000 characters

Created on 30 Sep 2015  路  6Comments  路  Source: k9mail/k-9

The relevant RFC-part is located here: https://tools.ietf.org/html/rfc5322#section-2.2.3

I tried to implement this in an easy way (as can be seen [here https://github.com/nilsbraden/k-9/commit/af0e20d252fbb18ef62ab8a6f90cf60b922a2923]) but the [pull request https://github.com/k9mail/k-9/pull/821#event-422173633] has been rejected. The folding should be implemented in a general way for all header fields and somewhere within the MimeMessage/MimeHeader classes.

I'm currently trying to find a good way to implement this and am unsure if this is the right way. To discuss this I opened this report.

My second attempt involves a lot of string operations. Since I read the RFC as recommending a split at several different characters I tried to implement a recursive function to try high-level splitting first and later other characters. This means I split at a space sign first, if lines with too many chars are still there I split at comma and so on. You can check this out here: https://gist.github.com/nilsbraden/f2a1eb7c762854aa553a (Code is not tested yet, just wrote it down...)

My current knowledge of the possible header fields and values is quite limited by what I have encountered so far. Does anybody know if it is a viable strategy to split at space, then comma, then semicolon, then do a hard split at 1000 characters to avoid invalid headers? Is it even allowed to split at a comma or semicolon in all header fields?

architecture enhancement

All 6 comments

Thanks a lot for continuing to look into this.

We should probably make sure that messages are only created via MessageBuilder. Then this class could be responsible for creating valid messages, including header folding and making sure bodies adhere to the line length limit.
It probably makes sense to do content-aware folding for specific headers. But in my opinion the code for folding addresses shouldn't live in Address itself but a separate class. It can then be used by MessageBuilder for the To, CC and BCC headers.
The same goes for other headers, like Content-Type. Things get even more complicated there. See https://github.com/k9mail/k-9/blob/2a404b30d22c7f6dfb2889954b6b5f57b725679a/k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java#L231

What is the progress on this issue? It has come up frequently the last years, including: https://github.com/k9mail/k-9/issues/2153

I stopped using K9 for different reasons but anyone please feel free to continue on this.

Old bug with no fix? :( Tripped over this today sending an email to >38 recipients, Gmail refuses emails which don't contain a valid From: header. Why isnt this getting any attention yet?

I am surprised to see that not many users are complaining about this.
organizing Gatherings & sports events using K9 is crippled by this limitation.

I know that this is totally unorthodox, but as a way of showing that I do truly care about this limitation, I will gladly offer a $50 donation (paypal) to whoever / whatever cause is selected by the person who is qualified enough to fix this (the fix has to be pushed to a release)
Ben

I'll match that $50.
@blachanc -- please post to the thread to whom the bounty was paid when/if you pay it.
Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ByteHamster picture ByteHamster  路  3Comments

asbach2 picture asbach2  路  3Comments

NovaViper picture NovaViper  路  3Comments

eleith picture eleith  路  3Comments

jimimaseye picture jimimaseye  路  3Comments