3 messages in net.sourceforge.lists.courier-maildrop[maildropl] Escaping single quotes do...
FromSent OnAttachments
Todd LyonsNov 29, 2005 11:47 am 
Sam VarshavchikNov 29, 2005 3:38 pm 
Todd LyonsNov 30, 2005 1:48 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[maildropl] Escaping single quotes doesn't seem to workActions...
From:Todd Lyons (tly@ivenue.com)
Date:Nov 29, 2005 11:47:41 am
List:net.sourceforge.lists.courier-maildrop

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?