Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

widgets/ansi: fallback to original text in case of parse error #1502

Closed
wants to merge 1 commit into from

Conversation

pacien
Copy link
Contributor

@pacien pacien commented May 4, 2020

Instead of crashing and leaving the user with a blank screen when
trying to open some messages containing non-handled escape codes.

GitHub: relates to #1493

@pazz
Copy link
Owner

pazz commented May 6, 2020

I guess a better solution would be to fix this parsing method.
Could you post the stack trace here? I forgot how to quickly add your buggy email...

@pacien
Copy link
Contributor Author

pacien commented May 6, 2020

I agree it would be better to fix the parser too so that correctly formatted emails are well-coloured.

But it is always possible to receive badly formatted emails with truely invalid ANSI escape codes that will crash the parser anyway. In this case it is still nice to be able to see the plaintext/unparsed version of those messages.

The stacktrace is in the issue #1493:

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)

I don't know whether there is a simpler way to open .eml files in alot, but I simply copy them to my maildir.

Instead of crashing and leaving the user with a blank screen when
trying to open some messages containing non-handled escape codes.

GitHub: relates to pazz#1493
pazz added a commit that referenced this pull request May 7, 2020
@pazz pazz mentioned this pull request May 7, 2020
@pazz
Copy link
Owner

pazz commented May 7, 2020

@pacien try my new branch on your email please.
I've re-written the parser and it should be much more selective and careful now.

@pazz
Copy link
Owner

pazz commented May 7, 2020

out of interest: what do you use to create ANSI codes? I only ever found elinks and it really isn't all that useful for those emails I receive..

@pacien
Copy link
Contributor Author

pacien commented May 7, 2020

@pacien try my new branch on your email please.
I've re-written the parser and it should be much more selective and careful now.

See my comment: #1503 (comment).
I'm closing this in favour of this new patch.

out of interest: what do you use to create ANSI codes? I only ever found elinks and it really isn't all that useful for those emails I receive..

The ANSI codes in the problematic example were generated by the output of a command that ran on a CI service and transmitted as is.

Otherwise, I'm trying to use colordiff to add some colours to inline patches that I receive, but adding a mailcap entry like below doesn't seem to have any effect.

.mailcap:

text/plain; cat %s | colordiff; copiousoutput

@pacien pacien closed this May 7, 2020
pazz added a commit that referenced this pull request May 8, 2020
pazz added a commit that referenced this pull request May 8, 2020
pazz added a commit that referenced this pull request May 8, 2020
pazz added a commit that referenced this pull request May 8, 2020
pazz added a commit that referenced this pull request May 8, 2020
Nelyah pushed a commit to Nelyah/alot that referenced this pull request May 8, 2020
GuillaumeSeren pushed a commit to GuillaumeSeren/alot that referenced this pull request Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants