[exim-dev] Patch for ACL add_header: delete/replace

Pàgina inicial
Delete this message
Reply to this message
Autor: Dave Evans
Data:  
A: exim-dev
Assumpte: [exim-dev] Patch for ACL add_header: delete/replace
Hi,

Please be gentle. This is my first exim-dev posting IIRC, and certainly my
first patch :-)

The attached patch extends the "add_header" ACL modifier to allow headers to
be deleted or replaced. However it gets a bit "fuzzy" when the headers in
question are repeated, so I'm open to suggestions as to whether something
needs to be changed, or whether this patch even fulfils a need at all.

# Delete all instances of the X-Whatever header
add_header = :delete:X-Whatever:
# Delete just the 2nd instance of the X-Whatever header
add_header = :delete:X-Whatever:2

# Find the first instance of the X-Whatever header; replace that header's value
# without moving it. If there was no such header, add it at the bottom.
add_header = :replace:X-Whatever:value goes here

Example usage:

# Prefix the Subject header by SPAM:, and add an X-Old-Subject header:
add_header = X-Old-Subject: ${sg{$h_subject:}{\n}{ }}
add_header = :replace:Subject: SPAM: ${sg{$h_subject:}{\n}{ }}

However the catch with that example is that if there are multiple Subject
headers, only the first is deleted (and replaced by the new one); subsequent
Subject headers are left intact. In which case you could try

add_header = :delete:Subject:
add_header = X-Old-Subject: ${sg{$h_subject:}{\n}{ }}
add_header = Subject: SPAM: ${sg{$h_subject:}{\n}{ }}

which works, but moves the Subject header to the end.

A final example (relevant to a current thread on exim-users): remove any
incoming Message-Id header (or the one generated by Exim) and replace it with
something else.

add_header = :replace:Message-Id: <.....>

Again, only marks the /first/ such header as deleted, if there's more than
one, so this may be preferable:

add_header = :delete:Message-Id:
add_header = Message-Id: <.....>

Thoughts anyone?

--
Dave Evans
Power Internet

PGP key: http://powernet.co.uk/~davide/pgpkey