Le 05/05/2012 05:47, /dev/rob0 a écrit :
> On Fri, May 04, 2012 at 10:03:35PM -0400, Wietse Venema wrote:
>> Vincent Lefevre:
>>> I've received a mail having:
>>>
>>> From: 
>>> =?GB2312?B?tfXBoyy2/rrP0ru19cGjLMj9us/Su7X1waMsy8S6z9K7tfXBoyy3/srOtfXB?=
>>>
>>> I wanted to reject such mail with
>>>
>>> /^.=\?GB2312\?B\?/   REJECT GB2312 in headers
> 
> The OP showed that on two lines, but if it is, there would be leading 
> whitespace. You want to match a whole logical header, not only a 
> continued line. The expression should be:
> 
> /^From:.=\?GB2312\?B\?/   REJECT GB2312 in headers
> 
> Or, remove the anchor:
> 
> /=\?GB2312\?B\?/   REJECT GB2312 in headers
> 
>>> in header_checks.pcre, but this didn't work. I don't understand 
>>> because
>>>
>>>   postmap -q - pcre:/etc/postfix/header_checks.pcre < the_message
>>>
>>> says that the rule applies on this line.
>>
>> Try:
>>
>>     postmap -h -q ....
>>
>> This way you enforce that it looks at headers only.
> 
> One thing the header_checks(5) manual is not clear about is how to 
> match the line end and leading whitespace. Is it matched by a single 
> space in the expression,

No: with the following header:
Received: from localhost (localhost [127.0.0.1])
          by russian-caravan.cloud9.net (Postfix) with ESMTP

$ cat  test.pcre
/^Received:.*\) by/     WARN match single space
/^Received:.*\)  by/     WARN match two spaces
/^Received:.*\)\s+by/     WARN match \s+
$ postmap -h -q - pcre:test.pcre < test.hdr
.... WARN match \s+



> or would we have to replace spaces with 
> something like this: "[[:blank:]]+" ?

with pcre, you can use \s+

/Received:\s*from\s+\S+\s+\(\S+\s+\[\S+\]\)\s+by\+\S+/

that looks a bit cryptic, doesn't it? :)

Reply via email to