Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add information to use mail-parser in an IMAP server #26

Closed
wants to merge 1 commit into from

Conversation

superboum
Copy link
Contributor

@superboum superboum commented Jul 8, 2022

It seems that my previous patch was not totally correct (for example, it does not work with DecodeResult::Borrowed).
So I have rewritten it to to use only stream.pos and state.mime_boundary.as_ref().
But I am not totally satisfied yet: the specific problem is when there is a RFC822 message contained in an RFC5322 message, mail-parser wrongly include the MIME delimiter from the parent in the child, RFC822 email. I want to fix it and validate all this logic on your test emails.

Retrospectively, I am not sure that offset_last_part is really needed, but having a body_raw in Part is required: an IMAP server must not decode content and return its raw size, not its decoded size.

Also, I am a bit worried with my new fields: it might break your tests, so we need to check that and maybe update them.
I will not be available in the next weeks but hope to finish this work until the end of the summer.

In the end, I think you should take into account this information if you want to make a release during this time: my previous PR might not be that great. If you really need to make a release, I would recommend that you rollback it.

Sorry, I thought that the problem might be easier to address.

Also fix Message.offset_last_part.
@superboum superboum marked this pull request as draft July 8, 2022 15:21
@mdecimus
Copy link
Member

mdecimus commented Jul 9, 2022

Unfortunately at the moment I do not have the time now to review this PR or implement this feature. Could you for the time being use these changes directly from your forked repository?
Another possibility is that your IMAP server re-encodes in Base64 all message parts instead of the returning the raw parts. But I am not sure how strict are the compliance tests run by Dovecot's imaptest.

@mdecimus
Copy link
Member

@superboum I had some time today and I was able to make these changes. Now each part contains the raw offsets for the header and body, you can obtain them as follows:

let (start, mid, end) = part.raw_offsets();

The headers would be raw_message[start..mid] while the contents are accessible using raw_message[mid..end].

Please could you check if they pass the Dovecot tests?

@mdecimus mdecimus closed this Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants