procmail
[Top] [All Lists]

Re: Special characters from recipe not escaped for the shell

2003-12-30 13:17:08
On 29 Dec 2003, at 08:55, Lee Hoffner wrote:

On Monday 29 December 2003 11:25 am, LuKreme wrote:
On 29 Dec 2003, at 08:15, Lee Hoffner wrote:
Hi, again. My recipe can break if there is an & in the subject line.
Here is a
sample log entry:

[Snip]

        TRAP= 'echo '`date`': HTML message from '$SPAMMER' with subject
'$SUB' was

This shell invocation is not escaped, so the '&' backgrounds the echo.

Can you elaborate, please? I don't understand: does 'echo ' need to be `echo
instead? I tried that earlier and the recipe didn't work at all.

The trap is assigned to, for example (ignoring quoting errors for now):

TRAP='echo Tue Dec 30 12:44:22 MST 2003: HTML message from loser(_at_)spam(_dot_)com with subject B&W pictures was'

now, when this is passed to the shell, the &, unescaped, becomes a background and the command fails.

You might try this:

TRAP='echo `date`: message from "$SPAMMER" with subject "$SUB" was logged'

which will give you:

Tue Dec 30 12:54:34 MST 2003: message from kremels(_at_)kreme(_dot_)com with subject Test #1 was logged Tue Dec 30 12:57:23 MST 2003: message from kremels(_at_)kreme(_dot_)com with subject test & test #2 was logged

now, if you want actual "'s in there, you will need to do something more like:

TRAP= 'echo `date`: message from "\"$SPAMMER\"" with subject "\"$SUB\"" was logged'

Tue Dec 30 13:03:01 MST 2003: message from "kremels(_at_)kreme(_dot_)com" with subject "test & test #2" was logged


--
Well I've seen the Heart of Darkness/Read the writing on the wall/and the voice out in the desert/Was the voice out in the hall

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail