pazz / alot

Terminal-based Mail User Agent
GNU General Public License v3.0
700 stars 163 forks source link

KeyError: 'content-transfer-encoding' #1508

Open josch opened 4 years ago

josch commented 4 years ago

Hi,

this issue exists on the current master branch commit d9533f1 with python 3.8.3rc1 on Debian unstable with notmuch 0.28.4-1. It can be reproduced using the following gzipped and base64 encoded spam message: ftpmaster.txt

The md5sum of the file should be f3155ef002e54cb514542705e51b7b88

I then run alot like this:

PYTHONPATH=$PWD python3 -m alot --debug-level=debug --logfile=log search id:E1jOzNV-000E0y-QG@fasolo.debian.org

I open the thread view and press gf (for togglesource) and am then getting this in the log file:

DEBUG:ui:Got key (['g'], [103])
DEBUG:ui:Got key (['f'], [102])
DEBUG:ui:cmdline: 'togglesource'
DEBUG:ui:thread command string: "togglesource"
DEBUG:__init__:mode:thread got commandline "togglesource"
DEBUG:__init__:ARGS: ['togglesource']
DEBUG:__init__:cmd parms {'query': [], 'raw': 'toggle'}
DEBUG:thread:matching lines None...
DEBUG:thread:setting focus to ('E1jOzNV-000E0y-QG@fasolo.debian.org', (0,)) 
DEBUG:thread:setting focus to ('E1jOzNV-000E0y-QG@fasolo.debian.org', (0,)) 
DEBUG:thread:collapsed False
DEBUG:thread:display_source True
DEBUG:thread:display_all_headers False
DEBUG:thread:display_attachements True
DEBUG:thread:display_mimetree False
DEBUG:thread:AHT None
DEBUG:thread:DHT <alot.widgets.thread.DictList object at 0x7f19d5587dc0>
DEBUG:thread:MAINTREE [(<MessageSummaryWidget selectable box/flow widget>, [(<alot.widgets.thread.DictList object at 0x7f19d5587dc0>, None), (<alot.widgets.thread.TextlinesList object at 0x7f19d548ebb0>, None)])]
ERROR:ui:Traceback (most recent call last):
  File "/tmp/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/tmp/alot/alot/commands/thread.py", line 624, in apply
    mt.reassemble()
  File "/tmp/alot/alot/widgets/thread.py", line 176, in reassemble
    self._maintree._treelist = self._assemble_structure()
  File "/tmp/alot/alot/widgets/thread.py", line 211, in _assemble_structure
    mainstruct.append((self._get_source(), None))
  File "/tmp/alot/alot/widgets/thread.py", line 247, in _get_source
    sourcetxt = self._message.get_email().as_string()
  File "/usr/lib/python3.8/email/message.py", line 968, in as_string
    return super().as_string(maxheaderlen=maxheaderlen, policy=policy)
  File "/usr/lib/python3.8/email/message.py", line 158, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib/python3.8/email/generator.py", line 116, in flatten
    self._write(msg)
  File "/usr/lib/python3.8/email/generator.py", line 189, in _write
    msg.replace_header('content-transfer-encoding', munge_cte[0])
  File "/usr/lib/python3.8/email/message.py", line 558, in replace_header
    raise KeyError(_name)
KeyError: 'content-transfer-encoding'