ph10 2005/06/07 11:41:27 BST
Modified files:
exim-doc/doc-txt ChangeLog
exim-src/src expand.c
exim-test-orig/AutoTest/scripts 082
exim-test-orig/AutoTest/stdout 082
Added files:
exim-test-orig/AutoTest/confs 616
exim-test-orig/AutoTest/log 616
exim-test-orig/AutoTest/scripts 616
exim-test-orig/AutoTest/stdout 616
Log:
Fix ${def: bug which treated "0" as false. Also diagnose syntax error of
unexpected characters after the variable name.
Revision Changes Path
1.149 +9 -0 exim/exim-doc/doc-txt/ChangeLog
1.23 +10 -7 exim/exim-src/src/expand.c
1.1 +28 -0 exim/exim-test-orig/AutoTest/confs/616 (new)
1.1 +3 -0 exim/exim-test-orig/AutoTest/log/616 (new)
1.13 +2 -1 exim/exim-test-orig/AutoTest/scripts/082
1.1 +4 -0 exim/exim-test-orig/AutoTest/scripts/616 (new)
1.13 +2 -1 exim/exim-test-orig/AutoTest/stdout/082
1.1 +2 -0 exim/exim-test-orig/AutoTest/stdout/616 (new)
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -r1.148 -r1.149
--- ChangeLog 6 Jun 2005 19:23:03 -0000 1.148
+++ ChangeLog 7 Jun 2005 10:41:26 -0000 1.149
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.148 2005/06/06 19:23:03 tom Exp $
+$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.149 2005/06/07 10:41:26 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
@@ -86,6 +86,15 @@
The latter is generated from $received_to and is only set if the
message has one envelope recipient. SA can use these headers,
obviously out-of-the-box. Patch from Alex Miller.
+
+PH/08 The ${def test on a variable was returning false if the variable's
+ value was "0", contrary to what the specification has always said!
+ The result should be true unless the variable is empty.
+
+PH/09 The syntax error of a character other than { following "${if
+ def:variable_name" (after optional whitespace) was not being diagnosed.
+ An expansion such as ${if def:sender_ident:{xxx}{yyy}} in which an
+ accidental colon was present, for example, could give incorrect results.
Exim version 4.51
Index: expand.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/expand.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- expand.c 23 May 2005 16:58:56 -0000 1.22
+++ expand.c 7 Jun 2005 10:41:27 -0000 1.23
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/expand.c,v 1.22 2005/05/23 16:58:56 fanf2 Exp $ */
+/* $Cambridge: exim/exim-src/src/expand.c,v 1.23 2005/06/07 10:41:27 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -1596,8 +1596,8 @@
cond_type = chop_match(name, cond_table, sizeof(cond_table)/sizeof(uschar *));
switch(cond_type)
{
- /* def: tests for a non-zero or non-NULL variable, or for an existing
- header */
+ /* def: tests for a non-empty variable, or for the existence of a header. If
+ yield == NULL we are in a skipping state, and don't care about the answer. */
case ECOND_DEF:
if (*s != ':')
@@ -1622,8 +1622,8 @@
(find_header(name, TRUE, NULL, FALSE, NULL) != NULL) == testfor;
}
- /* Test for a variable's having a non-empty value. If yield == NULL we
- are in a skipping state, and don't care about the answer. */
+ /* Test for a variable's having a non-empty value. A non-existent variable
+ causes an expansion failure. */
else
{
@@ -1635,8 +1635,7 @@
string_sprintf("unknown variable \"%s\" after \"def:\"", name);
return NULL;
}
- if (yield != NULL)
- *yield = (value[0] != 0 && Ustrcmp(value, "0") != 0) == testfor;
+ if (yield != NULL) *yield = (value[0] != 0) == testfor;
}
return s;
@@ -2321,11 +2320,15 @@
goto RETURN;
}
+/* The first following string must be braced. */
+
+if (*s++ != '{') goto FAILED_CURLY;
+
/* Expand the first substring. Forced failures are noticed only if we actually
want this string. Set skipping in the call in the fail case (this will always
be the case if we were already skipping). */
-sub1 = expand_string_internal(s+1, TRUE, &s, !yes);
+sub1 = expand_string_internal(s, TRUE, &s, !yes);
if (sub1 == NULL && (yes || !expand_string_forcedfail)) goto FAILED;
expand_string_forcedfail = FALSE;
if (*s++ != '}') goto FAILED_CURLY;
Index: 616
====================================================================
# Exim test configuration 616
# Macros are set externally in order to get the path
# of the Exim that is being tested, and the directory
# in which the test data lives.
exim_path = EXIM_PATH
primary_hostname = myhost.test.ex
spool_directory = DIR/spool
# ----- Main settings -----
acl_smtp_connect = check_connect
# ----- ACLs -----
begin acl
check_connect:
warn logwrite = START: >$acl_c0< >${if def:acl_c0{}{not }}defined<
set acl_c0 = 0
logwrite = SET 0: >$acl_c0< >${if def:acl_c0{}{not }}defined<
set acl_c0 = 1
logwrite = SET 1: >$acl_c0< >${if def:acl_c0{}{not }}defined<
accept
# End
Index: 616
====================================================================
1999-03-02 09:44:33 START: >< >not defined<
1999-03-02 09:44:33 SET 0: >0< >defined<
1999-03-02 09:44:33 SET 1: >1< >defined<
Index: 616
====================================================================
0 def:variable with a value of "0"
exim -bs
quit
****
Index: 082
===================================================================
RCS file: /home/cvs/exim/exim-test-orig/AutoTest/scripts/082,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- 082 10 May 2005 10:19:11 -0000 1.12
+++ 082 7 Jun 2005 10:41:27 -0000 1.13
@@ -192,6 +192,7 @@
def:f ${if def:post{y}{n}}
def:h_f ${if def:h_xxx {y}{n}}
def:h_f ${if def:h_xxx:{y}{n}}
+def:d: ${if def:tod_log:{y}{n}}
exists: ${if exists{/etc/passwd}{y}{n}}
exists: ${if exists{/doesnt}{y}{n}}
@@ -310,7 +311,7 @@
${lookup{x@y}lsearch*@{DIR/aux/082.starat}{$value}fail}
${lookup{x@z}lsearch*{DIR/aux/082.starat}{$value}fail}
${lookup{x@z}lsearch*@{DIR/aux/082.starat}{$value}fail}
-${lookup{x@w}lsearch*@{DIR/aux/082.starat}${$value}fail}
+${lookup{x@w}lsearch*@{DIR/aux/082.starat}{$value}fail}
${lookup{a.b.c.d}partial-lsearch{DIR/aux/082.domains}{$value}fail}
${lookup{x.y.z}partial-lsearch{DIR/aux/082.domains}{$value}{failed x.y.z}}
Index: 616
====================================================================
220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000
221 myhost.test.ex closing connection
Index: 082
===================================================================
RCS file: /home/cvs/exim/exim-test-orig/AutoTest/stdout/082,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- 082 10 May 2005 10:19:11 -0000 1.12
+++ 082 7 Jun 2005 10:41:27 -0000 1.13
@@ -188,6 +188,7 @@
> Failed: unknown variable "post" after "def:"
> def:h_f n
> def:h_f n
+> Failed: missing or misplaced { or }
>
> exists: y
> exists: n
@@ -306,7 +307,7 @@
> ==X@Y
> ==*
> ==*@Z
-> {==*
+> ==*
>
> data for a.b.c.d
> failed x.y.z