From owner-freebsd-questions@FreeBSD.ORG Wed Apr 5 19:31:54 2006 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53AFD16A41F for ; Wed, 5 Apr 2006 19:31:54 +0000 (UTC) (envelope-from norgaard@locolomo.org) Received: from strange.daemonsecurity.com (59.Red-81-33-11.staticIP.rima-tde.net [81.33.11.59]) by mx1.FreeBSD.org (Postfix) with ESMTP id C40F243D48 for ; Wed, 5 Apr 2006 19:31:53 +0000 (GMT) (envelope-from norgaard@locolomo.org) Received: from [172.16.2.1] (charm.daemonsecurity.com [172.16.2.1]) by strange.daemonsecurity.com (Postfix) with ESMTP id 548F22E04B for ; Wed, 5 Apr 2006 21:32:00 +0200 (CEST) Message-ID: <44341B14.9000800@locolomo.org> Date: Wed, 05 Apr 2006 21:31:32 +0200 From: =?UTF-8?B?RXJpayBOw7hyZ2FhcmQ=?= Organization: Locolomo.ORG User-Agent: Thunderbird 1.5 (X11/20060312) MIME-Version: 1.0 To: FreeBSD Questions Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Subject: Negative look ahead with capturing using pcre X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Apr 2006 19:31:54 -0000 Hi: I am trying to write some rules for filtering email with postfix header rules. In particular, I'd like to discard anything in a character set I don't understand, or rather accept ascii, iso-8859-* and utf-8. So I have created the following rule for mime header checks: /^Content-Type:.*?charset\s*=\s*"?(?!us-ascii|iso-8859-\d+|utf-8)(.*?)"?.*$/i WARN MHD1000 Invalid charset: "$1". Use UTF-8 or ISO-8859-X I have two problems: First: This rule catches a lot of legitimate mail, ascii or iso character sets Secondly: I'd like to catch the character set that is rejected so I can adjust it if legitimate mail gets blocked. In the above I don't allow windows-1252 for example. So, how do I do negative look ahead with capturing using pcre? Thanks, Erik -- Ph: +34.666334818 web: www.locolomo.org S/MIME Certificate: www.daemonsecurity.com/ca/8D03551FFCE04F06.crt Subject ID: 9E:AA:18:E6:94:7A:91:44:0A:E4:DD:87:73:7F:4E:82:E7:08:9C:72 Fingerprint: 5B:D5:1E:3E:47:E7:EC:1C:4C:C8:3A:19:CC:AE:14:F5:DF:18:0F:B9