<<< Date Index >>>     <<< Thread Index >>>

Re: Could not load html file to browser



On 2008-09-21, Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx> wrote:
> On Sunday, September 21 at 10:14 AM, quoth hce:
> > Hi,
> >
> > I set following definition in the muttrc on the Debian box:
> >
> > set implicit_autoview
> > alternative_order text/plain text/html
> 
> Okay... what does your text/html mailcap entry look like?
> 
> > When an email contains html format, the mutt called [-- Autoview 
> > using /usr/bin/w3m -dump -T text/html ''/tmp/mutt.html'' --]. But 
> > the html file could not be loaded to the browser as following error:
> 
> It sounds like your mailcap erroneously hardcoded the location of 
> temporary html files as /tmp/mutt.html, which is not what mutt uses.

Yes it is what mutt uses.  See the mutt manual and the tmpdir 
variable.  It defaults to "/tmp" unless the environment variable 
TMPDIR is set.

> > (1) Where is the autoview configurated to call /usr/bin/w3m -dump -T 
> > text/html?
> 
> It's defined in your mailcap file, either in ~/.mailcap or 
> /etc/mailcap. See your mailcap man page.

A better place to look would be the mutt manual again, since mutt 
determines the set of places it looks for a mailcap file.  The mutt 
manual mentions the following places:

   1. $HOME/.mailcap
   2. $PKGDATADIR/mailcap
   3. $SYSCONFDIR/mailcap
   4. /etc/mailcap
   5. /usr/etc/mailcap
   6. /usr/local/etc/mailcap

To find the values of $PKGDATADIR and $SYSCONFDIR used by your 
particular mutt, execute this command from the shell:

   mutt -v

> > (2) Why there is no /tmp/mutt.html? I tried to use vi to open 
> > /tmp/mutt.html, there was no that file either. That is why caused 
> > the browser eror to load a non exist /tmp/mutt.html file.
> 
> The short answer is: because there isn't *supposed* to be.

As I said above, it is supposed to be there.  I don't know why it's 
not.  There might be a clue in the error message:

   You tried to access the address file://localhost/tmp/mutt.html, 
   which is currently unavailable.

When I execute that command at the shell prompt (and /tmp/mutt.html 
doesn't exist), I get this error:

   $ w3m -dump -T text/html /tmp/mutt.html
   w3m: Can't load /tmp/mutt.html.

Ah, I think I see the problem.  It's in your w3m configuration.  
Start w3m from a shell prompt, then type 'o' to open the Option 
Setting Panel.  Scroll down to the Network Settings section and look 
for "Treat argument without scheme as URL".  I'll bet it is set to 
"YES".  Check the "NO" box instead, save the setting by hitting one 
of the "[OK]" links, and exit w3m.  Now try viewing that HTML e-mail 
again and see if it works.

> > (3) How to fix it in muttrc?
> 
> You can't. It has to be fixed in your mailcap.

If it turns out that changing that w3m option fixes the problem, but 
you want the setting changed only when you're using w3m with mutt, 
you can set the option instead as a command-line argument to w3m 
using w3m's -o option.  See the w3m man page.

> A correct mailcap entry should look something like this:
> 
>      text/html; w3m -dump -T text/html %s; needsterminal; copiousoutput;
> 
> Note the "%s" instead of "/tmp/mutt.html". That's so that mutt can 
> tell w3m where the temporary file is. It is usually something with an 
> unpredictable name (if it was a predictable name, it would be a 
> security problem), and NOT /tmp/mutt.html.

Well, in that case, I guess mutt 1.5.17 has a security problem.  
Mutt does use random file names for files to be edited, but not for 
files that are just viewed.

Regards,
Gary