Re: [exim] single quote question / problem

Top Page
Delete this message
Reply to this message
Author: Phil Pennock
Date:  
To: Nathan Hruby
CC: exim-users
Subject: Re: [exim] single quote question / problem
On 2009-06-01 at 17:45 -0500, Nathan Hruby wrote:
> Greetings!
>
> I was doing a quick proof of concept today and ran into an issue that
> I believe I've tracked down to exim treating the single quote
> character specially in some cases. For instance, given the following
> config:
>
> ====
> USER_EMAIL_OPT = ${lookup mysql{SELECT email_opt FROM user WHERE
> user_name = '${quote_mysql:$local_part}' AND user_status_type =
> 'active' LIMIT 1;} ${value}}
> SENDING_IP_CLASS = ${lookup ${sender_host_address}
> net24-iplsearch{CONFDIR/special_hosts} ${value}}


You want {$value}} not ${value}} here, I believe.

${lookup LOOKUP_TYPE{LOOKUP_QUERY}{EXPANSION_TRUE}{EXPANSION_FALSE}}

The {false-case} can omit the braces when the _keyword_ fail is used
instead of a string; the truth case always requires the enclosing
braces.

> I get the following error when running with exim -bhc:
> ====
> failed to expand condition "${if or { { eq {${lookup mysql{SELECT
> email_opt FROM user WHERE user_name = '${quote_mysql:$local_part}' AND
> user_status_type = 'active' LIMIT 1;} ${value}}}{a} } { eq {${lookup
> mysql{SELECT email_opt FROM user WHERE user_name =
> '${quote_mysql:$local_part}' AND user_status_type = 'active' LIMIT 1;}
> ${value}}}{${lookup ${sender_host_address}
> net24-iplsearch{/etc/exim/special_hosts} ${value}}} } } }" for
> users_forward router: missing or misplaced { or } inside "or{...}"
> condition
> ====


This seems to point to the above explanation being the problem.

> However, if I quote the leading single quote in USER_EMAIL_OPT by
> enclosing it with double quotes, using the hex ascii code for a single
> quote, escaping with a backslash, or escaping the "$" in the
> ${quote_mysql: then the condition successfully expands; however the
> expansion injects the unwanted escapes, backslashes, etc.. that I
> inserted in order to get it to exapnd into the sql query.


I *suspect*, but don't know, that what's happening here is the lookup is
failing to produce results, so ${value} is empty, so there's no syntax
error.

You might want to use "exim -d+expand -be" and test your expansions
interactively, looking at the results of the expansions.

-Phil