pazz/alot — Issue #365: mailcap %t and %{...}
Author: triumhiz
Created: 2012-02-26 11:17:33+00:00
State: open

As I understand, alot currently uses .mailcap file to find out which tool to use for html2text conversion.
It works fine with the following .mailcap entry:

text/html; /usr/bin/w3m -dump '%s'; copiousoutput; description=HTML Text; nametemplate=%s.html

But when I change the entry this way:

text/html; /usr/bin/w3m -T '%t' -dump '%s'; copiousoutput; description=HTML Text; nametemplate=%s.html

it fails with:
Error: unsupported format character 't' (0x74) at index 18,
check the log for details

Log file:
INFO:ui:setup gui in 256 colours
INFO:globals:open command shell
INFO:search:open thread view for thread:0000000000000682: Новое сообщение на Free-lance.ru

-T '%t' is not supposed to do anything useful here. What I need is %{charset} which is not handled by alot too.

My system 'run-mailcap' tool handles both sampled configuration entries correctly, so I suppose that alot uses its own implementation. Though I did not manage to make run-mailcap handle %{charset} yet.

Here is a paragraph from 'man run-mailcap':

The "command" field is any UNIX command ("cat %s" in the above exam‐
ple), and is used to specify the interpreter for the given type of
message. It will be passed to the shell via the system(3) facility.
Semicolons and backslashes within the command must be quoted with
backslashes. If the command contains "%s", those two characters
will be replaced by the name of a file that contains the body of the
message. If it contains "%t", those two characters will be replaced
by the content-type field, including the subtype, if any. (That is,
if the content-type was "image/pbm; opt1=something-else", then "%t"
would be replaced by "image/pbm".) If the command field contains
"%{" followed by a parameter name and a closing "}", then all those
characters will be replaced by the value of the named parameter, if
any, from the Content-type header. Thus, in the previous example,
"%{opt1}" will be replaced by "something-else". Finally, if the
command contains "\%", those two characters will be replaced by a
single % character. (In fact, the backslash can be used to quote
any character, including itself.)

If alot will handle successfully an entry like:
text/html; /usr/bin/w3m -T '%t' -o document_charset=%{charset} -dump '%s'; copiousoutput; description=HTML Text; nametemplate=%s.html

This is expected to solve #359 also.