Filtering non-ASCII characters with procmail and mutt

sheriff_p on 2005-05-04T09:04:19

Almost a year since my last entry, awesome... :-)

So here's a little snippet of my .procmailrc to remove characters I can't understand anyway from the subject and from lines, as mut is sending them straight to my terminal, and messing up my display:

# Rewrite the subject and sender to remove foreign characters
OLDSUBJECT=`/usr/local/bin/formail -xSubject:`
NEWSUBJECT=`echo $OLDSUBJECT | /usr/bin/tr -cs '\11\12\40-\176' 'Z'`

OLDSENDER=`/usr/local/bin/formail -xFrom:`
NEWSENDER=`echo $OLDSENDER | /usr/bin/tr -cs '\11\12\40-\176' 'Z'`

:0fw
|/usr/local/bin/formail -i "Subject: $NEWSUBJECT"

:0fw
|/usr/local/bin/formail -i "From: $NEWSENDER"


This won't work. And is a security risk.

muttley on 2006-04-19T11:33:57

As discussed on irc, and posted here for future posterity, you actually need

NEWSUBJECT=`echo "$OLDSUBJECT" | tr ...`

and

NEWFROM=`echo "$OLDFROM" | tr ...`