Mailspring/packages/local-sync/src/shared
Christine Spang 8238fe9594 [local-sync] Correctly handle messages with non-alternative multipart text bodies
Summary:
It's possible to have multiple inline HTML parts in a message, or even
a multipart/alternative part that contains text and HTML, followed by a
plaintext signature. Previously, if there was more than one text part in
an email, we would pick the _last_ text/html or text/plain part that we
found, and treat that as the entire message body. This works most of the
time, but fails to display the full message body in some edge cases.
This patch fixes that by resolving multipart/alternative subparts to a
single part in the mimepart fetch stage, and then treating each desired
mime part separately when parsing the message, concatenating them if
there are multiple.

This makes K2's handling of multipart MIME message text better,
bug-wise, than the Python sync engine's, which has been mangling some
rare messages forever. (Example from my email: every email from the MIT
EECS Jobs List has never displayed the mailing list signature in N1.)

Note that this patch also removes our tentative support for PGP
encrypted messages. I'd rather add that back in later when I've dug up
some real example messages to test on, rather than leaving it in in its
current not-really-tested and probably not-really-working state, since
it makes it harder to make sure that the rest of the logic isn't broken.

Test Plan: manual for now - added examples of this to my growing list of regression tests to add to the message parser unit tests once I fix them

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3600
2017-01-07 14:11:27 -08:00
..
database-extensions.js [local-sync] Increment streamAll offset by chunkSize (#5) 2016-12-09 11:15:04 -08:00
imap-paths-utils.js fix(tracking): Save updated metadata correctly and stop sending account ID with request 2016-12-19 15:40:38 -08:00
local-database-connector.js [local-sync] fix(specs): New specs for threading 2016-12-05 15:00:37 -08:00
logger.es6 [local-sync] only enable logging in dev mode of N1 2016-12-02 17:34:05 -05:00
message-factory.js [local-sync] Correctly handle messages with non-alternative multipart text bodies 2017-01-07 14:11:27 -08:00
transaction-connector.js [local-sync] fix unnecessary transaction JSON parse and binding issue 2016-11-23 13:43:00 -08:00
utils.js [local-sync] Port generic IMAP threading logic from Python Sync Engine 2017-01-07 13:11:33 -08:00