Skip to content

Commit

Permalink
Enable piping html to browser without scripts.
Browse files Browse the repository at this point in the history
Many browsers (including chromium) require that files end in the '.html'
extension in order to render them.
See <https://bugs.chromium.org/p/chromium/issues/detail?id=777737>.

When using `pipeto --format=mimepart --as_file`, on an html mime part, let's
automatically set the file extension.

This eliminates the need for additional user scripts referenced in
issues such as #789 and #1153.
  • Loading branch information
ryneeverett committed Mar 23, 2020
1 parent 6a53e26 commit 9203dbb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion alot/commands/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,9 @@ async def apply(self, ui):

# Pass mail as temporary file rather than piping through stdin.
if self.as_file:
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
suffix = {'html': '.html'}.get(mimepart.get_content_subtype())
with tempfile.NamedTemporaryFile(
delete=False, suffix=suffix) as tmpfile:
tmpfile.write(mail.encode(urwid.util.detected_encoding))
tempfile_name = tmpfile.name
mail = None
Expand Down

0 comments on commit 9203dbb

Please sign in to comment.