Re: [Exim] ip address mask operation in expansions

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Jakob Hirsch
CC: exim-users
Subject: Re: [Exim] ip address mask operation in expansions
On Sun, 28 Apr 2002, Jakob Hirsch wrote:

> (received_header_text) failed: "" is not an IP address'. Even when I try
> to catch this condition with def:sender_host_address like in this (used
> for testing):
>
> received_header_text = "Received: \
>   ${if def:sender_host_address \
>     {${mask:$sender_host_address/24}} \
>     {undefined} \
>   }"

>
> It seems that Exim tries to expand mask before evaluating the condition
> (which would not make much sense in my eyes) and fails because
> $sender_host_address is not defined. Or do I have to do this in another
> way?


You've found a small bug. Exim does have to inspect the substring, even
when the condition is false, in order to check its syntax. However, it
should avoid doing unnecessary operations (e.g. lookups) in substrings
that it is not going to use. Unfortunately, it isn't clever enough to
avoid trying to do "mask". I have made a note to fix this.

However, for the moment, you'll have to find some other way round the
problem. This ugly thing seems to work:

  ${if def:sender_host_address \
    { \
    ${mask:${if def:sender_host_address{$sender_host_address}{0.0.0.0}}/24} \
    } \
    {undefined}}


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