pazz / alot

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

Can't open plain text emails containing some ANSI escape codes #1493

Closed pacien closed 4 years ago

pacien commented 4 years ago

Describe the bug

Some emails containing ANSI terminal escape code trigger an error and cannot be opened instead of being displayed in a sanitised form.

(Terminal escape codes appear somewhat often in CI job notifications).

Software Versions

To Reproduce

Error Log

ERROR:ui:Traceback (most recent call last):
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/ui.py", line 718, in apply_command
    cmd.apply(self)
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/commands/globals.py", line 611, in apply
    ui.dbman.flush()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/db/manager.py", line 141, in flush
    afterwards()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/db/message.py", line 223, in myafterwards
    afterwards()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/commands/thread.py", line 1112, in refresh_widgets
    mt.refresh()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/thread.py", line 175, in refresh
    self.reassemble()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/thread.py", line 171, in reassemble
    self._maintree._treelist = self._assemble_structure()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/thread.py", line 213, in _assemble_structure
    bodytree = self._get_body()
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/thread.py", line 252, in _get_body
    self._bodytree = TextlinesList(bodytxt, att, att_focus)
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/thread.py", line 90, in __init__
    ansi_background), None))
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/ansi.py", line 18, in __init__
    ansi_background)
  File "/nix/store/3wf27s3sc21fbh9va1fp1iggqvi2mncz-python3.7-alot-0.8/lib/python3.7/site-packages/alot/widgets/ansi.py", line 72, in parse_escapes_to_urwid
    esc_code, esc_substr = part.split('m', 1)
ValueError: not enough values to unpack (expected 2, got 1)
pacien commented 4 years ago

Sloved in https://github.com/pazz/alot/pull/1503.