Re: header_checks rule that doesn't work
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? :)
Re: header_checks rule that doesn't work
On 2012-05-04 22:47:15 -0500, /dev/rob0 wrote: 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. Ah, OK, thanks, I hadn't seen this part of the doc. I think I was confused by http://www.postfix.org/BUILTIN_FILTER_README.html which says at the beginning: Postfix supports a built-in filter mechanism that examines message header and message body content, one line at a time, before it is stored in the Postfix queue. The following would be less confusing: Postfix supports a built-in filter mechanism that examines message header and message body content, one header or one body line at a time, before it is stored in the Postfix queue. -- Vincent Lefèvre vinc...@vinc17.net - Web: http://www.vinc17.net/ 100% accessible validated (X)HTML - Blog: http://www.vinc17.net/blog/ Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Re: header_checks rule that doesn't work
On 2012-05-05 12:41:35 +0200, mouss wrote: with pcre, you can use \s+ /Received:\s*from\s+\S+\s+\(\S+\s+\[\S+\]\)\s+by\+\S+/ ^^ \s+ that looks a bit cryptic, doesn't it? :) I wish pcre had a flag so that a space means \s+. That would particularly be useful here, where headers may be split at any whitespace. -- Vincent Lefèvre vinc...@vinc17.net - Web: http://www.vinc17.net/ 100% accessible validated (X)HTML - Blog: http://www.vinc17.net/blog/ Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Re: header_checks rule that doesn't work
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 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. Wietse
Re: header_checks rule that doesn't work
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, or would we have to replace spaces with something like this: [[:blank:]]+ ? -- http://rob0.nodns4.us/ -- system administration and consulting Offlist GMX mail is seen only if /dev/rob0 is in the Subject: