Mailcap Expandos

Moderators: 666philb, Forum moderators

Post Reply
geo_c
Posts: 3102
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2438 times
Been thanked: 964 times

Mailcap Expandos

Post by geo_c »

I'm putting this here because I'm working with the fossapup64.9.5 /etc/mailcap file in particular, but it may apply to puppy distros in general.

I came into this subject while struggling with the neomutt MIME viewing of txt/html parts of email messages. Below is a section of the neomutt manual where they suggest not quoting expandos. I tried it on the single line of the /etc/mailcap file: text/html; defaultbrowser %s And it solved my issues.

My question is: What applications might it be likely to break? And is there a specific reason the expandos are quoted in the fossapup /etc/mailcap file?

NeoMutt Reference:
3.2. Secure Use of Mailcap

The interpretation of shell meta-characters embedded in MIME parameters can lead to security problems in general. NeoMutt tries to quote parameters in expansion of %s syntaxes properly, and avoids risky characters by substituting them, see the $mailcap_sanitize variable.

Although NeoMutt's procedures to invoke programs with mailcap seem to be safe, there are other applications parsing mailcap, maybe taking less care of it. Therefore you should pay attention to the following rules:

Keep the %-expandos away from shell quoting. Don't quote them with single or double quotes. NeoMutt does this for you, the right way, as should any other program which interprets mailcap. Don't put them into backtick expansions. Be highly careful with evil statements, and avoid them if possible at all. Trying to fix broken behavior with quotes introduces new leaks – there is no alternative to correct quoting in the first place.

If you have to use the %-expandos' values in context where you need quoting or backtick expansions, put that value into a shell variable and reference the shell variable where necessary, as in the following example (using $charset inside the backtick expansion is safe, since it is not itself subject to any further expansion):

geo_c
Old School Hipster, and Such

Post Reply

Return to “Fossapup64”