summaryrefslogtreecommitdiff
path: root/alot/widgets
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-01-13 16:34:50 +0100
committerAnton Khirnov <anton@khirnov.net>2021-01-13 16:34:50 +0100
commitadbd0cb32d33a380c9ee92604b2d48cbc6f61c54 (patch)
treef0cbc568304b5c54e62ce9ec937b102daa056202 /alot/widgets
parent4baa4402d169d565977617505fffc59aade6dd23 (diff)
widgets/thread: skip zero-length alternatives
Some systems create multipart/alternative with an empty text/plain part, with actual content in the text/html part. Pretend the dummy plaintext part is not there.
Diffstat (limited to 'alot/widgets')
-rw-r--r--alot/widgets/thread.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py
index b6eb31d5..68e0ff34 100644
--- a/alot/widgets/thread.py
+++ b/alot/widgets/thread.py
@@ -359,7 +359,7 @@ class _TextPart(_MIMEPartWidget):
self._w = urwid.Text(markup_lines)
self._fold_level = val
-class _EmptyMessageWidget(_MIMEPartWidget):
+class _EmptyPartWidget(_MIMEPartWidget):
def __init__(self):
body_wgt = urwid.Text('<<< No displayable content >>>', align = 'center')
super().__init__(body_wgt)
@@ -368,7 +368,7 @@ def _handle_multipart(mime_tree, alternative_pref):
children = []
for child in mime_tree.children:
ch = _render_mime_tree(child, alternative_pref)
- if ch is not None:
+ if ch is not None and not isinstance(ch, _EmptyPartWidget):
children.append(ch)
if len(children) > 0:
@@ -396,7 +396,7 @@ def _render_mime_tree(mime_tree, alternative_pref):
# try rendering the message
text = mime_tree.render_str()
if text is not None:
- return _TextPart(text)
+ return _TextPart(text) if len(text) else _EmptyPartWidget()
body_wgt = urwid.Text('Undisplayable "%s" MIME part.' % mime_tree.content_type,
align = 'center')