bugfix: stop ignoring first line of imported email #484
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have stumbled upon a bug where almost all of the restored emails were corrupted. The emails in question seemed to have almost the same text but the formatting was all over the place and some of the words were mangled badly. HTML tables were broken.
Upon investigation I noticed that actual body of the email in the original .eml file and one downloaded from Googles "Download message" was practically identical with exception of few headers. One of those headers was
Content-Transfer-Encoding
which happened to be very first line of each corrupted email.Example diff:
After looking into the source code of
fmbox.py
I noticed that constructor ofclass fmbox()
advances theself._file
when initialising the_last_from_line
but does not rewind it back which effectively produces a message that is stripped of first line.Presumably this is not a problem when a message starts with a
From
header but it is when it's anything else.At this point I am not sure if this is provider specific or what, but for some context, my .eml files have been created by Proton Mail export tool. The same emails were imported from Google Takeout to Proton few years earlier if that matters.
I have tested the fix by importing about 500 messages and they all display correctly.
This is also likely related to the problem @infovations has seen in #148 as well as #157