Skip to content

Commit 7d11c9d

Browse files
committed
Enable piping html to browser without scripts.
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.
1 parent 57adcb4 commit 7d11c9d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

alot/commands/thread.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,9 @@ async def apply(self, ui):
769769

770770
# Pass mail as temporary file rather than piping through stdin.
771771
if self.as_file:
772-
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
772+
suffix = {'html': '.html'}.get(mimepart.get_content_subtype())
773+
with tempfile.NamedTemporaryFile(
774+
delete=False, suffix=suffix) as tmpfile:
773775
tmpfile.write(mail.encode(urwid.util.detected_encoding))
774776
tempfile_name = tmpfile.name
775777
mail = None

0 commit comments

Comments
 (0)