[Exim] Matching the NUL character in PCREs (exiscan 'regex')

Top Page
Delete this message
Reply to this message
Author: Tor Slettnes
Date:  
To: exim-users
Subject: [Exim] Matching the NUL character in PCREs (exiscan 'regex')
I have a problem I believe must be fairly common, but have not found an
optimal solution.

I deliver mail to Cyrus via an LMTP socket. Cyrus rejects mail with NUL
characters. Thus, I want to use a PCRE (specifically, a Exiscan-ACL
"regex" statement) to reject incoming mails with such characters, as
follows:

    deny message = Message contains NUL characters.
        regex = \000


I have not come up with any workable regular expression to do what I
want. Some of the ones I have tried are:

       [[::cntrl::]].*\r?\n\$
       [^[::print::][::space::]]
       \000
       \\000


As a workaround, I have setup the following filter in my "cyrus_lmtp"
transport:
       cyrus_lmtp:
           driver              = lmtp
           socket              = /var/run/cyrus/socket/lmtp
           transport_filter    = /usr/bin/tr -d \\000


However, I would rather not accept mails that contain the NUL character
in the first place (these are nearly always virii or badly encodes
spam).

Ideas?

Thanks,
-tor