Re: [exim] Wildlsearch - case-dependent?

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Philip Hazel
Datum:  
To: John Horne
CC: exim-users
Betreff: Re: [exim] Wildlsearch - case-dependent?
On Wed, 26 Jul 2006, John Horne wrote:

> Uppercase subject and lookup file key:
>
>    CONSIDERATION in "^(?-i)CONSIDERATION"? no (end of list)

>
> Lowercase subject and lookup file key:
>
>    consideration in "^(?-i)consideration"? yes (matched
> "^(?-i)consideration")

>
> Using mixed-case subject line:
>
>    CONsidERAtiOn in "^(?-i)consideration"? yes (matched
> "^(?-i)consideration")

>
> Now with uppercase lookup file key:
>
>    CONsidERAtiOn in "^(?-i)CONSIDERATION"? no (end of list)

>
>
> As can be seen an uppercase comparison failed, when it should have
> worked, but the lowercase one worked. Mixed-case shouldn't work at all,
> but one did. A bug?


Not a bug, but an infelicity, I grant you. In section 9.3 of the
reference manual it says, in the paragraphs describing wildlsearch and
nwildlsearch:

Like lsearch, the testing is done case-insensitively.

What this means is that the subject string is lower cased before any
comparisons are done, and the regular expression by default has the
case-insensitive flag set. In the case of a regex, lowercasing the
subject isn't actually necessary -- it's done for other kinds of
pattern.

The infelicity is that specifing (?-i) to change the case sensitivity of
the regex doesn't work, owing to the lower casing of the subject.

However, the good news is that I found a very small patch that makes it
work. The specification is now

Like lsearch, the testing is done case-insensitively, but in the case
of a regular expression, the use of (?-i) in the regex turns on case-
sensitive matching.

The patch is below. I will commit this shortly, so it will also be in
tonight's snapshot.

-- 
Philip Hazel            University of Cambridge Computing Service
Get the Exim 4 book:    http://www.uit.co.uk/exim-book




*** exim-4.62/src/match.c   Fri Apr 28 11:32:22 2006
--- match.c    Thu Jul 27 14:24:02 2006
***************
*** 108,113 ****
--- 109,120 ----


if (valueptr != NULL) *valueptr = NULL; /* For non-lookup matches */

+ /* For regular expressions, use cb->origsubject rather than cb->subject so that
+ it works if the pattern uses (?-i) to turn off case-independence, overriding
+ "caseless". */
+
+ s = (pattern[0] == '^')? cb->origsubject : cb->subject;
+
/* If required to set up $0, initialize the data but don't turn on by setting
expand_nmax until the match is assured. */