summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2006-07-27 13:50:43 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2006-07-27 13:50:43 +0000
commit366fc9f0fbb8ea549b36dc2f4afee4e92bf7d81d (patch)
treebabb97d32d708427a8677cb682b17b7a396e2ff7
parent084efe8d7243ef5184443e2c7075e80074476703 (diff)
Allow (?-i) to work as expected in a (n)wildlsearch key.
-rw-r--r--doc/doc-txt/ChangeLog8
-rw-r--r--src/src/match.c13
-rw-r--r--test/aux-var-src/0002.wild2
-rw-r--r--test/scripts/0000-Basic/00027
-rw-r--r--test/stdout/00027
5 files changed, 33 insertions, 4 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 71646ced2..d607ebdb1 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.383 2006/07/27 11:29:32 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.384 2006/07/27 13:50:43 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -140,6 +140,12 @@ PH/25 Exim was not testing for a space following SMTP commands such as EHLO
This bug exists in every version of Exim that I still have, right back to
0.12.
+PH/26 (n)wildlsearch lookups are documented as being done case-insensitively.
+ However, an attempt to turn on case-sensitivity in a regex key by
+ including (?-i) didn't work because the subject string was already
+ lowercased, and the effects were non-intuitive. It turns out that a
+ one-line patch can be used to allow (?-i) to work as expected.
+
Exim version 4.62
-----------------
diff --git a/src/src/match.c b/src/src/match.c
index 218944530..238a2cdea 100644
--- a/src/src/match.c
+++ b/src/src/match.c
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/match.c,v 1.14 2006/04/04 10:01:20 ph10 Exp $ */
+/* $Cambridge: exim/src/src/match.c,v 1.15 2006/07/27 13:50:43 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -74,7 +74,8 @@ Arguments:
returns ERROR)
Contents of the argument block:
- subject the subject string to be checked
+ origsubject the subject in its original casing
+ subject the subject string to be checked, lowercased if caseless
expand_setup if < 0, don't set up any numeric expansion variables;
if = 0, set $0 to whole subject, and either
$1 to what matches * or
@@ -99,7 +100,7 @@ check_string_block *cb = (check_string_block *)arg;
int search_type, partial, affixlen, starflags;
int expand_setup = cb->expand_setup;
uschar *affix;
-uschar *s = cb->subject;
+uschar *s;
uschar *filename = NULL;
uschar *keyquery, *result, *semicolon;
void *handle;
@@ -108,6 +109,12 @@ error = error; /* Keep clever compilers from complaining */
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. */
diff --git a/test/aux-var-src/0002.wild b/test/aux-var-src/0002.wild
index 826825725..f3202068e 100644
--- a/test/aux-var-src/0002.wild
+++ b/test/aux-var-src/0002.wild
@@ -9,3 +9,5 @@ abc: abc
^a\\.+b ^a\\.+b
\N^a\d+b \N^a\d+b
lsearch;DIR/aux-fixed/0002.quoted: lookup succeeded
+^(?-i)MiXeD-CD: Data found for case-dependent MiXeD-CD
+^MiXeD-nCD: Data found for case-independent MiXeD-nCD
diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002
index 7ff379c4f..251b8d0c5 100644
--- a/test/scripts/0000-Basic/0002
+++ b/test/scripts/0000-Basic/0002
@@ -387,6 +387,13 @@ a99b: ${lookup{a99b}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NO}}
a\\:b: ${lookup{a\\:b}nwildlsearch{DIR/aux-var/0002.wild}}
a\\:Xb: ${lookup{a\\:Xb}nwildlsearch{DIR/aux-var/0002.wild}}
+# Some tests of case-(in)dependence
+
+MiXeD-CD: ${lookup{MiXeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
+MixeD-CD: ${lookup{MixeD-CD}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
+MiXeD-Ncd: ${lookup{MiXeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
+MixeD-Ncd: ${lookup{MixeD-Ncd}nwildlsearch{DIR/aux-var/0002.wild}{$value}{NOT FOUND}}
+
# IP address (CIDR) lookups
1.2.3.4: ${lookup{1.2.3.4}iplsearch{DIR/aux-fixed/0002.iplsearch}}
diff --git a/test/stdout/0002 b/test/stdout/0002
index 8e3c661b3..e437faded 100644
--- a/test/stdout/0002
+++ b/test/stdout/0002
@@ -356,6 +356,13 @@
> a\:b: ^a\\.+b
> a\:Xb: ^a\\.+b
>
+> # Some tests of case-(in)dependence
+>
+> MiXeD-CD: Data found for case-dependent MiXeD-CD
+> MixeD-CD: NOT FOUND
+> MiXeD-Ncd: Data found for case-independent MiXeD-nCD
+> MixeD-Ncd: Data found for case-independent MiXeD-nCD
+>
> # IP address (CIDR) lookups
>
> 1.2.3.4: data for 1.2.3.4