Regexp matching, filtering

Top Page
Delete this message
Reply to this message
Author: Eelco Vriezekolk
Date:  
To: exim-users
Subject: Regexp matching, filtering
Hello,

I am trying to set up a system filter, but instead of rejecting
mail I would first like to have the filter freeze 'suspect' messages
so that I can still have them delivered if my filter turns out to be
too strict.

I want to freeze messages from
    <four-letters>@<same-four-letters><two-letters>.net
e.g. s5j8@??? or orqp@???


To do so, I set up this filter:

  if $sender_address_domain matches
^${sender_address_local_part}..\\.net\$
  then
     testprint "Frozen: $sender_address_local_part
$sender_address_domain matches
     freeze
  endif


That worked fine, until I noticed its incorrectness on receiving an
email message from an address

asdf**qwer@???

The problem is that characters that have a special meaning in regular
expressions can legally appear with an address (the "." for example).
On this above address, for example, the regexp expands to

^asdf**qwer..\.net$

and Exim complains about the ** in the regular expression. Is there
any way to safely use a $variable within a regexp? I'm a bit
puzzled here.
Perhaps a ${quote:$variable} expantion operator would be useful? (To
put backslashes in, where necessary).

Thanks,
--
Eelco Vriezekolk, eelco@???
Postmaster and systems administrator, UUNET Internet Africa (Swaziland)
Find me in the Swaziland Email Directory: http://www.directory.sz/email
Voice: +268 44705 Fax: +268 44783

--
* This is sent by the exim-users mailing list.  To unsubscribe send a
    mail with subject "unsubscribe" to exim-users-request@???
* Exim information can be found at http://www.exim.org/