Re: HTML mail which isn't handled correctly by 'auto_view text/html

2019-02-06 Thread Cameron Simpson

On 06Feb2019 13:01, Chris Green  wrote:

On Wed, Feb 06, 2019 at 01:00:48PM +1100, Cameron Simpson wrote:

Scenario B:
If DHL really are sending HTML in a standalone text/plain body then 
you've got 2 choices.


The first is to act when you receive the email; if you're using procmail or
something similar to file you email you could match these messages and
modify the Content-Type: header to say "text/html".

The alternative is to match the message with mutt, and to set display_filter
specially for this message. You could use your normal display_filter and use
a message-hook to override it with the command from the mailcap ("lynx
-dump").


OK, thanks, it's quite rare and, at the moment, only DHL notifications
doing this that I actually want to see the content.


Just further to the display_filter thing: I normally use a 
display_filter, set to a personal script which goes:


   #!/bin/sh
   #
   # Mutt display filter, whose behaviour adjusts accoridng to some flags.
   #   - Cameron Simpson  29jan2017
   #

   if flag MUTT_ROT13
   then  tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'
   else  cat
   fi \
   | if flag MUTT_UNTOPPOST
 then  untoppost
 else  cat
 fi \
   | mutt-highlight

The mutt-highlight is a sed script which turns *foo* into bold and _foo_ 
into underlined. But the important thing here is the if statement: it 
optionally runs the message body through some filters. For example, I've 
got a mutt macro ^X to toggle the MUTT_ROT13 flag and redisplay the 
message.


You could adopt such a scheme for your HTML issue (in fact, I'm going to 
do that myself too): have an optional flag to decode the HTML using a 
pipeline flavour of your mailcap unhtml line. Then bind a mutt keystroke 
to toggle the flag and redisplay. My rot13 bindings go:


   set my_toggle_rot13="$my_push_wait_key=noflag !  MUTT_ROT13 -e 
flag MUTT_ROT13$my_pop_wait_key"
   macro index \Cx "$my_toggle_rot13" 'toggle MUTT_ROT13'
   macro pager \Cx "$my_toggle_rot13" 'toggle MUTT_ROT13'

Just a thought. Source for any of the above is available.

Cheers,
Cameron Simpson 


Re: HTML mail which isn't handled correctly by 'auto_view text/html

2019-02-06 Thread Chris Green
On Wed, Feb 06, 2019 at 01:00:48PM +1100, Cameron Simpson wrote:
> On 05Feb2019 22:10, Chris Green  wrote:
> > I am getting notification E-Mails from DPD which aren't handled
> > correctly by 'auto_view text/html' in my muttrc and 'text/html; lynx
> > -dump %s; copiousoutput; nametemplate=%s.html' in .mailcap.
> > 
> > Presumably it's simply that there is no 'text/html' string in the
> > headers, I just get to see the raw HTML.  In fact there is the
> > following:-
> > 
> >...
> >...
> >...
> >Subject: Your order 3179771 is due for delivery by DHL Parcel UK
> >Content-Type: multipart/alternative;
> >boundary="--boundary_145134_db6b4c85-2751-452f-bf4b-c56010b07587"
> >Message-ID:
> >
> >Status: RO
> >Content-Length: 20807
> >Lines: 285
> > 
> >Content-Type: text/plain; charset="us-ascii"
> >Content-Transfer-Encoding: quoted-printable
> > 
> >
> >
> >
> >
> >...
> >...
> >...
> > 
> > So that would explain it!  Is there any way to manually ask mutt to
> > treat this as text/html?
> 
> Kinda.
> 
> Firstly, is that really the entirely of the relevant headers? No text/html
> or multipart/mixed? DHL are really sending HTML notifications (ugh!)
> identified as text/plain? That is a new low.
> 
Yes!  It's the only message I've ever received (well, I've received a
couple of these from DHL recently) which has done this to me.
Everyone else's HTML (spit) E-Mail gets fed into Lynx correctly.


> (My previous low is the many senders who send multipart/mixed with either
> the HTML duplicated in the text/plain half or outright absent - empty
> text/plain half.)
> 
> So: are DHL sending _only_ an text/plain section or both text/plain and
> text/html? In my experience it is usually the latter.
> 
There's only the HTML, identified as plain!


> Scenario A: Both text/html and text/plain, but the text/plain contains HTML.
> I get this a lot. I have this in my muttrc:
> 
Not this I think.

> 
> Scenario B:
> 
> If DHL really are sending HTML in a standalone text/plain body then you've
> got 2 choices.
> 
> The first is to act when you receive the email; if you're using procmail or
> something similar to file you email you could match these messages and
> modify the Content-Type: header to say "text/html".
> 
> The alternative is to match the message with mutt, and to set display_filter
> specially for this message. You could use your normal display_filter and use
> a message-hook to override it with the command from the mailcap ("lynx
> -dump").
> 
OK, thanks, it's quite rare and, at the moment, only DHL notifications
doing this that I actually want to see the content.

-- 
Chris Green