On 4/22/2011 3:21 PM, b...@bitrate.net wrote:
i'm experimenting with removing certain "internal" received
headers, and am having trouble constructing a proper header
check to match headers which span multiple lines.
cat test_message
Delivered-To: f...@example.com
Return-Path: <b...@example.net>
Received: from localhost (localhost [127.0.0.1])
by mta.example.com (Postfix) with ESMTP id 76ABF40DF1
for <u...@example.com>; Tue, 19 Apr 2011 22:50:30 -0400 (EDT)
From: "b...@example.net" <b...@example.net>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: tuesday's meeting
Date: Thu, 21 Apr 2011 21.47.30 -0400
To: "f...@example.com" <f...@example.com>
Mime-Version: 1.0
X-Mailer: mail client
today's meeting will be today
cat header_checks-ignored
/^Received: from localhost \(localhost \[127\.0\.0\.1\]\)\s+by
mta\.example\.com \(Postfix\) with ESMTP id/ IGNORE
#/^Received: from localhost \(localhost \[127\.0\.0\.1\]\)/
IGNORE
postmap -q - regexp:./header_checks-ignored < test_message
if i use the shorter version, it works, so i believe i'm using
proper syntax and test method.
Your test method is flawed. See
http://www.postfix.org/postmap.1.html
paying particular attention to the "-h" flag.
If you have an old postfix that doesn't have the postmap -h
flag, you'll need to fold your headers into single lines
before testing.
how can i construct a header
check for a header in which it may not be known where exactly
in the string a newline will be found, and how much whitespace
might be interspersed?
For pcre: maps, use \s+ to represent whitespace, including
multiple spaces, newlines, or tabs. Not all regexp: libraries
(provided by your OS, not by postfix) recognize \s. You may
need to use [[:space:]]+ instead if you don't have pcre.
Your test was flawed, and \s may not be valid with your regexp
library.
thanks
-ben
Peace,
-- Noel Jones