Re: Viewing HTML message with Firefox

2022-10-08 Thread Cameron Simpson

On 08Oct2022 21:55, Jan Eden via Mutt-users  wrote:
Thank you! This works well with Epiphany, but Firefox still fails 
(which

I do not care about, as long as I have a working browser option).


My recollection is that this is a timing issue. To run the viewer mutt 
goes:

- make a temp file containing the message or html
- run the mailcap command
- remove the temp file

Your command is "open", which tells firefox (your default browser) to 
open the file for viewing. That message takes little time. By the time 
firefox gets around to opening the file (probably after making the new 
browser window) the file has been removed by step 3 above.


This is why helper scripts like Chris Green's one take a copy of the 
file. They tell the browser to view the copy, which does not get 
removed.


As a hack, you might find it enough to include a short sleep in your 
command, enough to allow firefox to latch onto the message:


open %s && sleep 3

My personal process, which is by no means seamless, is a macro bond to 
my "V" key:


macro index,pager V "mail-open-attachments" "extract 
attachments to temp dir and open"
macro attach  V "qVv" "extract attachments to temp dir and open"

and the associated script is here:

https://github.com/cameron-simpson/css/blob/main/bin/mail-open-attachments

Like Chris' script, it makes a copy.

It unpacks everything in the message into a directory, then opens the 
Finder on that directory. Then I can use preview on the HTML or open it 
in Firefox. Etc etc for whatever other attachments there may have been.


Cheers,
Cameron Simpson 


Re: Re: Re: Viewing HTML message with Firefox

2022-10-08 Thread Jan Eden via Mutt-users

On 2022-10-08 11:52, Chris Green wrote:
> On Sat, Oct 08, 2022 at 12:06:52PM +0200, Jan Eden via Mutt-users wrote:
> > On 2022-10-08 09:34, Chris Green wrote:
> > > On Sat, Oct 08, 2022 at 10:25:29AM +0200, Jan Eden via Mutt-users wrote:
> > > > Hi,
> > > > 
> > > > I recently configured mutt on a Linux system, and cannot display HTML
> > > > messages in the default browser. mailcap contains the following lines:
> > > > 
> > > > text/html; open %s;
> > > > text/html; w3m -I %{charset} -T text/html; copiousoutput
> > > > application/pdf; open %s; copiousoutput
> > > > 
> > > > w3m is used automatically (auto_view text/html), and PDF documents are
> > > > opened correctly in evince.
> > > > 
> > > > But when I try to open an HTML message manually, Firefox displays either
> > > > a permission denied error (with AppArmor enabled), or a file not found
> > > > error – both pointing to the message's filename.
> > > > 
> > > > How can I allow Firefox to access and display the message?
> > > > 
> > > I no longer use Firefox on my xubuntu system (I've moved to Vivaldi)
> > > but I seem to remember that Firefox's security paranoia means that you
> > > now have to explicitly configure to allow access to files on the local
> > > system.
> > 
> > With AppArmor disabled, Firefox tries to display the message, but cannot
> > find the message file in /var/tmp/ – %s seems to point to that
> > directory.
> > 
> > In Firefox' settings, I did not find any parameter to keep the browser
> > from accessing local files.
> > 
> > > By 'manually' I presume you mean v[iew] the message parts and then
> > > m[view-mailcap] the html.
> > 
> > Yes.
> > 
> When I view an HTML message like this the address is like:-
> 
> file:///srv/mutt/mutt-esprimo-1000-151542-10027422769961820949.html
> 
> I use a script (called via mailcap) to store the HTML message in that
> directory.
> 
> So, in mailcap I have:-
> 
> [...]
> 
> You don't need the bit for remote viewing from my laptop, just the "running 
> locally"
> bit.

Thank you! This works well with Epiphany, but Firefox still fails (which
I do not care about, as long as I have a working browser option).

- Jan


signature.asc
Description: PGP signature


Re: Re: Viewing HTML message with Firefox

2022-10-08 Thread Chris Green
On Sat, Oct 08, 2022 at 12:06:52PM +0200, Jan Eden via Mutt-users wrote:
> On 2022-10-08 09:34, Chris Green wrote:
> > On Sat, Oct 08, 2022 at 10:25:29AM +0200, Jan Eden via Mutt-users wrote:
> > > Hi,
> > > 
> > > I recently configured mutt on a Linux system, and cannot display HTML
> > > messages in the default browser. mailcap contains the following lines:
> > > 
> > > text/html; open %s;
> > > text/html; w3m -I %{charset} -T text/html; copiousoutput
> > > application/pdf; open %s; copiousoutput
> > > 
> > > w3m is used automatically (auto_view text/html), and PDF documents are
> > > opened correctly in evince.
> > > 
> > > But when I try to open an HTML message manually, Firefox displays either
> > > a permission denied error (with AppArmor enabled), or a file not found
> > > error – both pointing to the message's filename.
> > > 
> > > How can I allow Firefox to access and display the message?
> > > 
> > I no longer use Firefox on my xubuntu system (I've moved to Vivaldi)
> > but I seem to remember that Firefox's security paranoia means that you
> > now have to explicitly configure to allow access to files on the local
> > system.
> 
> With AppArmor disabled, Firefox tries to display the message, but cannot
> find the message file in /var/tmp/ – %s seems to point to that
> directory.
> 
> In Firefox' settings, I did not find any parameter to keep the browser
> from accessing local files.
> 
> > By 'manually' I presume you mean v[iew] the message parts and then
> > m[view-mailcap] the html.
> 
> Yes.
> 
When I view an HTML message like this the address is like:-

file:///srv/mutt/mutt-esprimo-1000-151542-10027422769961820949.html

I use a script (called via mailcap) to store the HTML message in that
directory.

So, in mailcap I have:-

text/html; /home/chris/bin/muttview %s html

... and muttview is:-

!/bin/bash
#
#
# muttview:  script called by mutt via mailcap to view attachments
# and HTML e-mail (where lynx isn't good enough).
#
# The temporary file to be viewed is copied to directory
# /srv/mutt on esprimo if running locally or to the same place on the
# remote system if running via ssh.  The copy to the remote system is
# done using rsync to an rsync daemon on t470 via a reverse tunnel
# set up when the ssh connection is made.
#
dir=/srv/mutt
fn=$1
if [ "$2" == "html" ]
then
mv $fn $fn.html
fn=$fn.html
fi
#
#
# if there's no DISPLAY variable then the viewer can't run, so skip the 
whole thing
#
if [ -n "$DISPLAY" ]
then
if [ -n "$SSH_CLIENT" ]; then
#
#
# view on t470, files dropped into /srv/mutt there are 
automatically displayed
#
export RSYNC_PASSWORD=brzmi
rsync $fn rsync://chris@localhost:50873/tv/$(basename $fn)
else
#
#
# running locally, copy to /srv/mutt and then select viewer on file 
type
#
dest=$dir/$(basename $fn)
cp $fn $dest
 
shopt -s nocasematch
case $fn in
*.html)
$BROWSER file://$dest
;;
*.pdf)
atril $dest &
;;
*)
nomacs $dest >/dev/null 2>&1 &
;;
esac
fi
fi
#
#
# Clear out any old files left on esprimo by this script, doing it here
# saves adding a special crontab task (but a crontab task is needed on t470)
#
find $dir -mtime +7 -exec rm {} \;

You don't need the bit for remote viewing from my laptop, just the "running 
locally"
bit.

-- 
Chris Green


Re: Re: Viewing HTML message with Firefox

2022-10-08 Thread Jan Eden via Mutt-users
On 2022-10-08 09:34, Chris Green wrote:
> On Sat, Oct 08, 2022 at 10:25:29AM +0200, Jan Eden via Mutt-users wrote:
> > Hi,
> > 
> > I recently configured mutt on a Linux system, and cannot display HTML
> > messages in the default browser. mailcap contains the following lines:
> > 
> > text/html; open %s;
> > text/html; w3m -I %{charset} -T text/html; copiousoutput
> > application/pdf; open %s; copiousoutput
> > 
> > w3m is used automatically (auto_view text/html), and PDF documents are
> > opened correctly in evince.
> > 
> > But when I try to open an HTML message manually, Firefox displays either
> > a permission denied error (with AppArmor enabled), or a file not found
> > error – both pointing to the message's filename.
> > 
> > How can I allow Firefox to access and display the message?
> > 
> I no longer use Firefox on my xubuntu system (I've moved to Vivaldi)
> but I seem to remember that Firefox's security paranoia means that you
> now have to explicitly configure to allow access to files on the local
> system.

With AppArmor disabled, Firefox tries to display the message, but cannot
find the message file in /var/tmp/ – %s seems to point to that
directory.

In Firefox' settings, I did not find any parameter to keep the browser
from accessing local files.

> By 'manually' I presume you mean v[iew] the message parts and then
> m[view-mailcap] the html.

Yes.

- Jan


signature.asc
Description: PGP signature


Re: Viewing HTML message with Firefox

2022-10-08 Thread Chris Green
On Sat, Oct 08, 2022 at 10:25:29AM +0200, Jan Eden via Mutt-users wrote:
> Hi,
> 
> I recently configured mutt on a Linux system, and cannot display HTML
> messages in the default browser. mailcap contains the following lines:
> 
> text/html; open %s;
> text/html; w3m -I %{charset} -T text/html; copiousoutput
> application/pdf; open %s; copiousoutput
> 
> w3m is used automatically (auto_view text/html), and PDF documents are
> opened correctly in evince.
> 
> But when I try to open an HTML message manually, Firefox displays either
> a permission denied error (with AppArmor enabled), or a file not found
> error – both pointing to the message's filename.
> 
> How can I allow Firefox to access and display the message?
> 
I no longer use Firefox on my xubuntu system (I've moved to Vivaldi)
but I seem to remember that Firefox's security paranoia means that you
now have to explicitly configure to allow access to files on the local
system.

By 'manually' I presume you mean v[iew] the message parts and then
m[view-mailcap] the html.

-- 
Chris Green


Viewing HTML message with Firefox

2022-10-08 Thread Jan Eden via Mutt-users
Hi,

I recently configured mutt on a Linux system, and cannot display HTML
messages in the default browser. mailcap contains the following lines:

text/html; open %s;
text/html; w3m -I %{charset} -T text/html; copiousoutput
application/pdf; open %s; copiousoutput

w3m is used automatically (auto_view text/html), and PDF documents are
opened correctly in evince.

But when I try to open an HTML message manually, Firefox displays either
a permission denied error (with AppArmor enabled), or a file not found
error – both pointing to the message's filename.

How can I allow Firefox to access and display the message?

Thanks,
Jan


signature.asc
Description: PGP signature