[elinks-users] elinks + mutt: problems with utf-8 encoding

Kalle Olavi Niemitalo kon at iki.fi
Wed Oct 15 12:38:55 PDT 2008

Witold Filipczyk <witekfl at poczta.onet.pl> writes:

> text/html; elinks -dump -eval 'set document.codepage.assume = "%{charset}"' %s; copiousoutput

The Mutt manual recommends not putting quotes around %.
there under "Secure use of mailcap".  Mutt's default
mailcap_sanitize=yes should prevent command injections though.

If we wanted not to rely on mailcap_sanitize, so that the mailcap
file could be safely used by programs other than Mutt, the first
attempt might be:

text/html; charset=%{charset} && elinks -dump -eval \
"set document.codepage.assume = \"$charset\"" %s; copiousoutput

However, that still isn't quite right, because even though
%{charset} is now properly quoted for the shell, it could be
misparsed by ELinks if it contains quotes, and then you could get
e.g. 'include "/dev/urandom"' in the -eval.  How to fix this:

(a) Note that ELinks does not actually support any charsets whose
    names contain quotes, and add some shell commands to reject
(b) Filter the string through sed in order to escape any quotes.
(c) Change ELinks to support elinks -assume-codepage %{charset}.
    Then the configuration file parser would not be involved.
(d) Change ELinks to support elinks -set document.codepage.assume
    %{charset}, so that other options can be set in the same way.
    But would we then want a similar command-line option for
    set_domain as well?

If document.codepage.assume is the only option that needs to be
settable in this way, I think approach (c) would be reasonable,
and easy to implement.

More information about the elinks-users mailing list