diff options
author | Philip Hazel <ph10@hermes.cam.ac.uk> | 2005-06-07 10:41:26 +0000 |
---|---|---|
committer | Philip Hazel <ph10@hermes.cam.ac.uk> | 2005-06-07 10:41:26 +0000 |
commit | 9b4768fabd99041ceb2e3958814127df4caf2a79 (patch) | |
tree | a8dc6b76079589823a606e8a366ebba692ca39e2 | |
parent | 5f9708466e6fc22453a69e20524d69c05ef6a0b3 (diff) |
Fix ${def: bug which treated "0" as false. Also diagnose syntax error of
unexpected characters after the variable name.
-rw-r--r-- | doc/doc-txt/ChangeLog | 11 | ||||
-rw-r--r-- | src/src/expand.c | 19 |
2 files changed, 21 insertions, 9 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 2ff3afb40..fb3c3124b 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.148 2005/06/06 19:23:03 tom Exp $ +$Cambridge: 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 ------------------------------------------- @@ -87,6 +87,15 @@ TK/07 MBOX spool code: Add X-Envelope-From: and X-Envelope-To: headers. 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 ----------------- diff --git a/src/src/expand.c b/src/src/expand.c index b0c1d5340..9daf77d0b 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/expand.c,v 1.22 2005/05/23 16:58:56 fanf2 Exp $ */ +/* $Cambridge: 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 @@ if (name[0] == 0) 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 @@ switch(cond_type) (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 @@ switch(cond_type) 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 @@ if (*s == '}') 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; |