Re: [exim] Remove header lines matching a specific pattern?

Góra strony
Delete this message
Reply to this message
Autor: Heiko Schlittermann
Data:  
Dla: exim-users
Temat: Re: [exim] Remove header lines matching a specific pattern?
Heiko Schlittermann <hs@???> (Di 14 Jul 2009 09:30:24 CEST):
> Phil Pennock <exim-users@???> (Di 14 Jul 2009 04:55:19 CEST):
> > On 2009-07-14 at 00:35 +0200, Heiko Schlittermann wrote:
> > > I'm still at my version - instead of cutting away the tail, I'm
> > > selecting the head of the logical header line:
> > >
> > > ${lc:${sg {$message_headers_raw}{\N(?m)(^\S+(?=\s*):)?.*?\n\N}{\$1}}}
> >
> > The \S+(?=\s*): part doesn't do what I think you think it does.
> >
> > (?=foo) is a zero-width positive lookahead assertion. It matches if and
> > only if followed by foo, but does *not* advance the "current position"
> > past foo.
> >
> > So X(?=\s*): will match if, after matching X, it can match zero or more
> > spaces and then, immediately after X, match a colon. In the degenerate
> > case of zero spaces, this works. But it won't match when there is
> > space.
> >
> > ${lc:${sg {$message_headers_raw}{\N(?m)(?:(^\S+)\s*(:))?.*?\n\N}{\$1\$2}}}
> >
> > I suggest taking a mail header for your -bem test file and inserting
> > some whitespace for testing purposes.
>
> ohohoho, I just wanted to show you that it does what I thing it should
> do, using my mail file (according to your suggestion yesterday) - and -
> voila - it doesn't do what I think it should do. I'm missing the
> "To : fred" header :-( and I don't know why I didn't see it yesterday.


What about this:

The input for exim -bem

    |From: hans
    |To  : peter
    |Received: from me
    |   by you
    |   for him
    |Subject: nix


The pattern 
    ${lc:${sg {$message_headers_raw}{\N(?m)(^\S+)?\s*(:)?.*?\n\N}{\$1\$2}}}


The result
    from:to:received:subject:message-id:date:



    Best regards from Dresden/Germany
    Viele Grüße aus Dresden
    Heiko Schlittermann
-- 
 SCHLITTERMANN.de ---------------------------- internet & unix support -
 Heiko Schlittermann HS12-RIPE -----------------------------------------
 gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
 gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2  7E92 EE4E AC98 48D0 359B -