RE: [Exim] Quick Regex Query

Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Philip Hazel
Ημερομηνία:  
Προς: Andrew Chant
Υ/ο: exim-users
Αντικείμενο: RE: [Exim] Quick Regex Query
On Wed, 25 Apr 2001, Andrew Chant wrote:

> I am making progress, what I have for a condition is as follows.
>
> condition = "${if and {\
>         {match {$h_Received:}{^.*domain.com.*\\$}{false}{true}}\
>         {match {$sender_address_domain}{${lookup
> mysql{VIRUS_DOMAIN}{$value}fail}}{true}{false}}\
>         } {1} {0}}"

>
> All I seem to get is "missing or misplaced { or }".


1. (Get your editor or something to) Count the curlies: 17 of each, so
that's OK.

2. Get rid of the quoting. It isn't necessary because you don't have any
special characters, and it adds an additional layer of \ escaping,
which is just confusing. You can then turn \\$ into \\.

3. However, your problem is in the "and" condition"; its arguments
should be sub-conditions.

condition = ${if and {\
        {match {$h_Received:}{^.*domain.com.*\$}{false}{true}}\


That line is the first subcondition - but it isn't a condition. You have
stuck {false}{true} on the end.

        {match {$sender_address_domain}
          { ${lookup mysql{VIRUS_DOMAIN}{$value}fail}} {true}{false}
        }


Likewise, that isn't condition.

        } {1} {0}}


Try this (but get rid of my comments:

 condition = ${if and {\           test several conditions


First condition: "Received:" contains domain.com:

{match {$h_Received:}{domain\\.com}}\

Your condition specified that Received: *ends* in domain.com, which I
doubt is what you want. You might perhaps want to improve the regex to
something like \\.domain\\.com\\b or possibly \\.domain\\.com(\\s|\$).

Second condition: match sender address to a regex that is looked up:

   {match \
      {$sender_address_domain}\                     first arg for match
      {${lookup mysql{VIRUS_DOMAIN}{$value}fail}}\  second arg for match
   }\                                               completes match condition
  }\                  complete "and" condition
 {1} {0}}             yes/no values for "and"



-- 
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.