astroid icon indicating copy to clipboard operation
astroid copied to clipboard

Can't open HTML parts

Open rothn opened this issue 2 years ago • 5 comments

Since I'm copying some from https://github.com/astroidmail/astroid/issues/19, I will bold the original parts. It seems I feel much the same way as OP so I'll let them do (most) of the talking:

Hi,

I've just started using Astroid but I really like it so far, so thanks!

I can't seem to open HTML parts though. I've tried pressing o or enter after navigating to the alternative part with j/k with the email selected but this just opens up a search box. I have "open_html_part_external": "true", in my config and i've set "open_external_link" to point to Firefox (also tried it with the default xdg-open which is installed an I've tested from the command line). I also have the default "external_open_cmd": "xdg-open".

The text for the external part says "Alternative part (type: text/html) - potentially sketchy." but there doesn't seem to be any way to open it once highlighted (or ideally show html by default)

I'm sure I'm missing something obvious but I've run out of ideas, sorry!

rothn avatar Sep 08 '23 03:09 rothn

If I set "preferred_type": "html" in the config file, I can get the very top of HTML emails to load, but it's usually just the header (e.g. stylized "INSIDE DAILY BRIEF") without the content.

rothn avatar Sep 08 '23 03:09 rothn

Rebasing onto https://github.com/ibuclaw/astroid/tree/remove_iframes fixes the display issue where only the top of the emails load, but I still have the original issue of not being able to open a selected part. Please advise as to a fix. For now, I am just setting html as my preferred type as a workaround but I really would like to be able to open other parts of multipart messages, like attachments.

rothn avatar Sep 08 '23 04:09 rothn

  1. Do I understand correctly that you cannot even open attachments?
  2. Does any part of the problem show up if you set open_html_part_external to false? (given you applied #740 or #747; you can check out pull requests locally)

jorsn avatar May 31 '24 19:05 jorsn

I cannot reproduce this completely. When I press 'o', after navigating to the alternative part, it opens the search box. When I press enter, it opens firefox with the correct html file, which has however already been deleted by astroid. So, for me, this seems to be the actual issue:

When Astroid opens a attachment and the external program detaches (runs in the background), then astroid deletes the cached file. But how do we get around this? How can astroid know that the file isn't being displayed any more?

jorsn avatar Jun 29 '24 17:06 jorsn

I once tried something with inotifywait, but for me, everything seems to be fixed if I set attachment.external_open_cmd to the following shell script

#!/usr/bin/env bash

xdg-open "$1"
sleep 1s

Thus, firefox can read the file before the process exits and astroid deletes the file.

@rothn If you still encounter the issue, please write so. For now, I will not consider this for the new release (#750).

jorsn avatar Jun 29 '24 21:06 jorsn