-
Notifications
You must be signed in to change notification settings - Fork 64
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
Handle messages as bytes internally in order to support multiple encoding types #48
Comments
I have started a possible patch that makes the changes I was trying to describe, using the built-in email library to simplify processing the messages (adding/searching for headers, deleting them, etc) It also handles the conversion between line break types when outputting the message, negating the need to mangle it for certain functions. The changes impact what is passed to some of the function calls, so it will require some testing and I have yet to standup a dummy email server to test with. Furthermore, I have not yet made the changes to the GMAIL classes, and would have further difficulty testing those changes eventually. A fork of offlineimap3 with the changes so far can be found here: https://github.com/jishac/offlineimap3/tree/multiple_encoding_support |
Should finalize implementation of enhancement OfflineIMAP#48 OfflineIMAP#48 And fix issues OfflineIMAP#43 and OfflineIMAP#44 OfflineIMAP#43 OfflineIMAP#44
…s well and I reviewed the code several times. However, I cannot test it, testers wanted! This commit: Minor bug fixes from testing Should finalize implementation of enhancement OfflineIMAP#48 OfflineIMAP#48 And fix issues OfflineIMAP#43 and OfflineIMAP#44 OfflineIMAP#43 OfflineIMAP#44 Signed-off-by: Joseph Ishac <jishac@nasa.gov> Tested-by: Joseph Ishac <jishac@nasa.gov>
Thanks for this @jishac. Your PR is definitely a huge improvement and this almost works. But I am seeing one problem in gmail. Not sure about other mail servers.
This message is fetched properly by offlineimap3 and if I open using vim I can see all the characters properly and it also gives me But if I reply to that above mail from Gmail web interface and the reply is:
Then it is not fetched properly and if I see the fetched message using vim I get:
Tried sending the same reply message using mutt and the message body is correct but the subject is: But all the messages are displayed properly in Gmail interface. |
I just checked with old offlineimap (python 2) and it had the same behaviour. So, I will say the regression is now fixed and the problem I mentioned can be a feature request. |
@sudipm-mukherjee I'm not sure I understand the concern/issue. The content you posted:
I imagine if you view the source or original in gmail, you will probably see the same text verbatim. That source is valid and would open correctly in mutt. This is what I get plugging the above into mutt:
As for the difference in subject lines, both are valid RFC 1522 encodings in the format of |
Thanks @jishac. I am not seeing any issue if I open those mails using mutt, I only got the problem as I tried to open them using vim instead of mutt. So, no issues or concern. Please ignore what I said. |
Hello!! @sudipm-mukherjee could we close this issue too? Thanks a lot! |
Correct, this has been completed/closed. |
Feature Request
It would be great if OfflineIMAP could leverage the built-in email libraries to store messages as a byte array and avoid unnecessary conversions to strings. Currently, OfflineIMAP will read the input file as text and then does a hard conversion to bytes assuming utf-8 encoding when interfacing to the IMAP server. This results in exceptions when something other than plain ascii or utf-8 are present in the email (see bugs #43 and #44 ). Furthermore, an email can contain multiple encodings (see attached test mail) and thus a solution that searches for one form of encoding would be problematic.
The built in library can help keep track of the multiple encodings if needed and do conversions based on the capabilities of the IMAP server. I imagine it should even simplify the \r\n and \n conversions sprinkled through the code.
I have attached a test email and simple python script (both with txt extensions) that I used as a simple proof of concept.
Test Message containing several different encodings (mbox format for easy viewing in a mail client)
testmail-mime.txt
Simple Python3 script that attempts to keep the message intact while still adding the X-OfflineIMAP header
py3.email-copy.txt
The text was updated successfully, but these errors were encountered: