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

support for Content-Type: application/pkcs7-mime #1541

Open
josch opened this issue Aug 10, 2020 · 0 comments
Open

support for Content-Type: application/pkcs7-mime #1541

josch opened this issue Aug 10, 2020 · 0 comments

Comments

@josch
Copy link
Contributor

josch commented Aug 10, 2020

Hi,

I received an email with these headers:

Content-Type: application/pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Disposition: attachment; filename="smime.p7m"
Content-Transfer-Encoding: base64
X-Mailer: Microsoft Outlook 16.0

The body of the mail is a big base64 encoded blob. When encoding that blob I get:

This is a multipart message in MIME format.

------=_NextPart_000_034D_01D660D6.B4137450
Content-Type: text/plain;
	charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

[message text]

------=_NextPart_000_034D_01D660D6.B4137450
Content-Type: application/pkcs7-signature;
	name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="smime.p7s"

[base64 encoded signature]
------=_NextPart_000_034D_01D660D6.B4137450--

The main problem is, that currently, when this email is in my search results, I get:

ERROR:ui:Traceback (most recent call last):
  File "/home/josch/git/alot/alot/ui.py", line 723, in apply_command
    cmd.apply(self)
  File "/home/josch/git/alot/alot/commands/globals.py", line 125, in apply
    ui.buffer_open(buffers.SearchBuffer(ui, self.query,
  File "/home/josch/git/alot/alot/ui.py", line 417, in buffer_open
    self.buffer_focus(buf)
  File "/home/josch/git/alot/alot/ui.py", line 477, in buffer_focus
    self.update()
  File "/home/josch/git/alot/alot/ui.py", line 668, in update
    self.mainloop.draw_screen()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 586, in draw_screen
    canvas = self._topmost_widget.render(self.screen_size, focus=True)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/decoration.py", line 226, in render
    canv = self._original_widget.render(size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 1085, in render
    body = self.body.render((maxcol, maxrow-ftrim-htrim),
  File "/home/josch/git/alot/alot/buffers/buffer.py", line 19, in render
    return self.body.render(size, focus)
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 144, in cached_render
    canv = fn(self, size, focus=focus)
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 470, in render
    middle, top, bottom = self.calculate_visible(
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 353, in calculate_visible
    self._set_focus_complete( (maxcol, maxrow), focus )
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 717, in _set_focus_complete
    return self._set_focus_first_selectable(
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 687, in _set_focus_first_selectable
    middle, top, bottom = self.calculate_visible(
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 356, in calculate_visible
    focus_widget, focus_pos = self._body.get_focus()
  File "/home/josch/git/alot/alot/walker.py", line 39, in get_focus
    return self._get_at_pos(self.focus)
  File "/home/josch/git/alot/alot/walker.py", line 72, in _get_at_pos
    widget = self._get_next_item()
  File "/home/josch/git/alot/alot/walker.py", line 85, in _get_next_item
    next_widget = self.containerclass(next_obj, **self.kwargs)
  File "/home/josch/git/alot/alot/widgets/search.py", line 26, in __init__
    self.rebuild()
  File "/home/josch/git/alot/alot/widgets/search.py", line 60, in rebuild
    width, part = build_text_part(partname, self.thread,
  File "/home/josch/git/alot/alot/widgets/search.py", line 145, in build_text_part
    content = prepare_string(name, thread, maxw)
  File "/home/josch/git/alot/alot/widgets/search.py", line 213, in prepare_string
    s = content(thread)
  File "/home/josch/git/alot/alot/widgets/search.py", line 188, in prepare_content_string
    lastcontent = ' '.join(m.get_body_text() for m in msgs)
  File "/home/josch/git/alot/alot/widgets/search.py", line 188, in <genexpr>
    lastcontent = ' '.join(m.get_body_text() for m in msgs)
  File "/home/josch/git/alot/alot/db/message.py", line 287, in get_body_text
    return extract_body_part(self.get_mime_part())
  File "/home/josch/git/alot/alot/db/utils.py", line 499, in extract_body_part
    **{'field_key': 'view'} if body_part.get_content_type() == 'text/plain'
AttributeError: 'str' object has no attribute 'get_content_type'

And the thread will not show up at all. This is not nice.

So in this feature request, I do not want to ask for support for smime signed emails, but just for the ability to:

  • have these emails show up in the search results
  • be able to read the body part

Thanks!

cheers, josch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants