From: Jeremy Harris Date: Tue, 2 Sep 2014 22:37:57 +0000 (+0100) Subject: Fix ${extract expansion for use within ${if inlist etc. Bug 1524 X-Git-Tag: exim-4_85_RC1~66 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/82dbd376b5de9b9d91e93e91a4e058a80a43de99 Fix ${extract expansion for use within ${if inlist etc. Bug 1524 The coding of the numeric test on the key decided that empty was numeric, and insisted on a third substring even in syntax-check "skip" mode. This failed when a single expansion variable was used for the key (eg. $item) and the defaults for string2, string3 were being assumed. Skip the test in skip mode. --- diff --git a/src/src/expand.c b/src/src/expand.c index 8111c4212..a929e937c 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -2752,6 +2752,8 @@ switch(cond_type) uschar *save_iterate_item = iterate_item; int (*compare)(const uschar *, const uschar *); + DEBUG(D_expand) debug_printf("condition: %s\n", name); + tempcond = FALSE; if (cond_type == ECOND_INLISTI) compare = strcmpic; @@ -2839,6 +2841,8 @@ switch(cond_type) int sep = 0; uschar *save_iterate_item = iterate_item; + DEBUG(D_expand) debug_printf("condition: %s\n", name); + while (isspace(*s)) s++; if (*s++ != '{') goto COND_FAILED_CURLY_START; /* }-for-text-editors */ sub[0] = expand_string_internal(s, TRUE, &s, (yield == NULL), TRUE, resetok); @@ -5229,25 +5233,28 @@ while (*s != 0) while (len > 0 && isspace(p[len-1])) len--; p[len] = 0; - if (*p == 0 && !skipping) - { - expand_string_message = US"first argument of \"extract\" must " - "not be empty"; - goto EXPAND_FAILED; - } + if (!skipping) + { + if (*p == 0) + { + expand_string_message = US"first argument of \"extract\" must " + "not be empty"; + goto EXPAND_FAILED; + } - if (*p == '-') - { - field_number = -1; - p++; - } - while (*p != 0 && isdigit(*p)) x = x * 10 + *p++ - '0'; - if (*p == 0) - { - field_number *= x; - j = 3; /* Need 3 args */ - field_number_set = TRUE; - } + if (*p == '-') + { + field_number = -1; + p++; + } + while (*p != 0 && isdigit(*p)) x = x * 10 + *p++ - '0'; + if (*p == 0) + { + field_number *= x; + j = 3; /* Need 3 args */ + field_number_set = TRUE; + } + } } } else goto EXPAND_FAILED_CURLY;