Skip to content

Commit

Permalink
restore lenient libmagic decoding
Browse files Browse the repository at this point in the history
176cffc ("refactor alot.db.utils.remove_cte", 2018-12-04) created a few
problems with 8bit quoted-printable e-mails, see #1291 #1360.

This commit restores the old libmagic fallback which did not cause this
problem.
  • Loading branch information
mjg authored and pazz committed Feb 7, 2019
1 parent 0a55181 commit 61b1c65
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
4 changes: 2 additions & 2 deletions alot/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ def remove_cte(part, as_string=False):
sp = helper.try_decode(bp)
except UnicodeDecodeError as emsg:
# the mail contains chars that are not enc-encoded.
# try again and just ignore those
# libmagic works better than just ignoring those
logging.debug('Decoding failure: {}'.format(emsg))
sp = bp.decode(enc, errors='ignore')
sp = helper.try_decode(bp)
return sp
return bp

Expand Down
1 change: 0 additions & 1 deletion tests/db/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ def test_require_mailcap_file(self):

self.assertEqual(actual, expected)

@unittest.expectedFailure
def test_simple_utf8_file(self):
mail = email.message_from_binary_file(
open('tests/static/mail/utf8.eml', 'rb'))
Expand Down

0 comments on commit 61b1c65

Please sign in to comment.