diff options
author | Jeremy Harris <jgh146exb@wizmail.org> | 2014-09-02 23:37:57 +0100 |
---|---|---|
committer | Jeremy Harris <jgh146exb@wizmail.org> | 2014-09-02 23:53:28 +0100 |
commit | 82dbd376b5de9b9d91e93e91a4e058a80a43de99 (patch) | |
tree | c9cf48af80702bca9e733208e8af26189cd76023 | |
parent | 0f06b4f296802e4e13188c740ea09419931a3020 (diff) |
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.
-rw-r--r-- | src/src/expand.c | 43 |
1 files changed, 25 insertions, 18 deletions
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; |