thunderbird / thunderbird/thunderbird-android
non uri addressable attachments
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 14k
- Forks
- 2.8k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 57
Description
We still have a bit of a situation with our handling of attachments. Here is a rough overview of our parsing control flow, to get on the same page:
- data is loaded from the database into one
LocalMessageand severalLocalBodyParts - encrypted message parts are decrypted, recursively parsing the mime structure of the decrypted data. for all further processing, the decrypted
MimeBodyParts are substituted for their encryptedLocalParts MessageExtractor.findViewablesAndAttachmentssubdivides all parts of a message into those parts which are displayed inline as part of the message text, and those which are displayed as attachments
4a) Inline parts are parsed into text, and concatenated intoMessageViewInfo.text
4b) Attachment parts are parsed intoAttachmentViewInfoobjects, which hold info on the attachments including a content-URI (which may be handed to external apps to access the part data)
The problematic bit is that for step 4b), all parts to be displayed as attachments need to be addressable by a URI. This is generally fine for parts loaded from the database. For the decrypted parts from step 2), all leaf parts have a body of class DeferredFileBody, for which a URI can be obtained through DecryptedFileProvider.
A problem arises if MessageExtractor in step 3) decides that any decrypted, non-leaf part should be displayed as an attachment. At the moment, the only situation where this can happen is a message/rfc822 part with content-disposition: attachment.
Possible solutions:
- Don't recursively parse message/rfc822 parts with content-disposition attachment in
MimePartStreamParser, but treat them as a leaf body. This is a relatively simple solution to the problem, and has good performance because we don't parse a mime structure that is never used later on. However, it breaks separation of concerns, since the decision how a part should be displayed (inline/attachment) is supposed to be made inMessageExtractor. - In
AttachmentInfoExtractor, write theMimeBodyPartback into a file that can be accessed throughDecryptedFileProvider. Worse for performance since it means we needlessly parse the message structure just to write it down at a later point. This also breaks separation of concerns but in a different way, since it assigns responsibility toAttachmentInfoExtractorto not only find a URI to access a part, but to create it in the first place.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with MimePartStreamParser, MessageExtractor.findViewablesAndAttachments, AttachmentInfoExtractor, and DecryptedFileProvider to trace how decrypted message/rfc822 attachments are parsed and addressed. Compare the listed alternatives and define a resolution that gives every attachment a usable URI without assigning display decisions to the wrong component; no specific implementation or test is named.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100