Re: [exim] celaning up header comments

Top Page
Delete this message
Reply to this message
Author: Phil Pennock
Date:  
To: Randy Bush
CC: exim users
Subject: Re: [exim] celaning up header comments
On 2009-04-02 at 14:32 +0900, Randy Bush wrote:
> sorry, this is a really sick one.
>
> for an mua, i use wanderlust under emacs and use bbdb as the address
> book maintainer.  bbdb views 
>      "Bob Jones" <bob@???>
> as different from
>     "'Bob Jones'" <bob@???>

>
> i am trying to get the time to hack bbdb, but it's not an easy hack.
>
> is there some cute way to hack this in the local delivery?


If you want to keep as much as possible, then you use a transport_filter
on the local delivery transport. You could then use Perl to adjust as
needed; eg:
----------------------------8< cut here >8------------------------------
#!/usr/bin/perl
use warnings;
use strict;

my %convs = map {$_=>1} ('from', 'to', 'cc', 'resent-from', 'resent-to', 'resent-cc');
my $addr_header = 0;

while (<>) {
    last if /^$/;
    if (/^(\S+)\s*:/) {
        $addr_header = exists $convs{lc $1};
    }
    unless ($addr_header) { print; next; }
    s/"'([^']+)'"/"$1"/g;
    print;
}
print "\n";
while (<>) {
    print;
}
----------------------------8< cut here >8------------------------------


If you want to avoid the external invocations then it's more
problematic; I can't think of a way yet. If you wanted to just get rid
of the display names then you could use a value like:

${substr_4:${reduce {${addresses:$h_cc:}}{""}{$value, $item}}}

in a System Filter of
----------------------------8< cut here >8------------------------------
# Exim filter

headers add "X-Local-CC: ${substr_4:${reduce {${addresses:$h_cc:}}{""}{$value, $item}}}"
headers remove "Cc:"
headers add "Cc: $h_x_local_cc:"
headers remove "X-Local-CC"
----------------------------8< cut here >8------------------------------

and repeat that CC: stuff for To:, From:, Resent-{To,From,CC}:, etc etc.
That also works for comments in addresses.

But I don't know of a way to take an email header and turn it into a
list of items which includes the display nams and comments in each item.

-Phil