Re: [Exim] Problem with quote_mysql

Pàgina inicial
Delete this message
Reply to this message
Autor: Philip Hazel
Data:  
A: Björn Metzdorf
CC: exim-users
Assumpte: Re: [Exim] Problem with quote_mysql
On Fri, 23 Mar 2001, Björn Metzdorf wrote:

> I am using Exim version 3.22 #7 built 11-Feb-2001 18:58:14 and I seem to
> have a problem with quote_mysql.
>
> In one of my routers (special_local, as stated in the FAQ) I use
>
> MYSQL_LOCAL_DOMAINS = SELECT DISTINCT MYSQL_DOMAINFIELD FROM MYSQL_AUTHTABLE
> WHERE MYSQL_USERNAMEFIELD = '${quote_mysql:$local_part}' AND
> MYSQL_DOMAINFIELD = '${quote_mysql:$domain}' AND MYSQL_ACTIVEFIELD = 'yes'
>
> domains = mysql;MYSQL_LOCAL_DOMAINS
>
> The problem arises when a destination email contains a ' in $local_part
> (lets say foo'bar@???), debug shows that
>
> '${quote_mysql:$local_part}'
>
> expands to
>
> 'foo'bar'


That's odd, because a simple test shows differently:

$ exim -be
> ${quote_mysql:abc'def}

abc\'def

AHA! I know what it is. How confusing. This is the problem:

The "domains" option is expanded as a single string, so that it can be
varied according to the circumstances. So you end up with

domains = .... 'foo\'bar' ...

However, when operating on a domain list, an item which involves a
query-type lookup is also expanded before it is run, so that $key can be
inserted. This happens because lists like relay_domains are not normally
expanded. ("domains" on a router/director is special in this regard).

So, your string is being expanded twice, and the second expansion is
taking away the backslash. What you need to do is to use

'\${quote_mysql:$local_part}'

so that the quoting happens at the lower level.

I agree that this is a confusing "gotcha". Sorry.

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