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

Reply via email to