Here is a snippet of code that I'm working on in my maildroprc:
/^Subject: !.*/
log "Match: $MATCH2"
SUBJECT=$MATCH2
SUBJECT=escape($SUBJECT)
log "Subject: $SUBJECT"
`test -f $HOME/vacation.subject`
if ( $RETURNCODE == 0 )
{
SUBJECTHEADER=`/bin/head -n 1 $HOME/vacation.subject`
SUBJECTHEADER=escape($SUBJECTHEADER)
}
else
{
SUBJECTHEADER="Auto-Reply"
}
xfilter "reformail -r -t -I 'From: ${LOGNAME}' -I 'X-Loop: Vacation for
${LOGNAME}' -I 'Reply-To: $LOGNAME' -I 'Auto-Submitted: auto-replied' -I
'Precedence: junk' -I 'Subject: ${SUBJECTHEADER}: ${SUBJECT}'"
I am seeing that any subject with a single quote causes problems. It
basically closes the single quote of the Subject header that it's
inserting. For example, with the subject line:
We've received: War of the Worlds
the above command expands to:
xfilter "reformail -r -t ...
... -I 'Subject: Auto-Reply: We've received: War of the Worlds'"
Do you see the single quote that's screwing it up? The escape()
function doesn't seem to do it. I've have resolved it by piping to sed,
but it seems that the escape function should take care of this. This is
my work around:
/^Subject: !.*/
log "Match: $MATCH2"
SUBJECT=$MATCH2
if ( $SUBJECT =~ /'/ )
{
SUBJECT=`echo $SUBJECT | /bin/sed -r "s/['\"]/ /g"`
}
log "Subject: $SUBJECT"
`test -f $HOME/vacation.subject`
if ( $RETURNCODE == 0 )
{
SUBJECTHEADER=`/bin/head -n 1 $HOME/vacation.subject`
SUBJECTHEADER=escape($SUBJECTHEADER)
}
else
{
SUBJECTHEADER="Auto-Reply"
}
xfilter "reformail -r -t -I 'From: ${LOGNAME}' -I 'X-Loop: Vacation for
${LOGNAME}' -I 'Reply-To: $LOGNAME' -I 'Auto-Submitted: auto-replied' -I
'Precedence: junk' -I 'Subject: ${SUBJECTHEADER}: ${SUBJECT}'"
Can anybody suggest anything better?