From: Jeremy Harris Date: Sun, 26 Feb 2017 01:07:47 +0000 (+0000) Subject: Fix ${extract } corrupting an enclosing ${reduce } $value. Bug 2061 X-Git-Tag: exim-4_89_RC7~7 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/232874e8705380a0819d460d24c01476d69971be?ds=sidebyside;hp=d9841333e40c16d12df8190527a0ceba233f4c93 Fix ${extract } corrupting an enclosing ${reduce } $value. Bug 2061 Broken-by: 20fcb1e7be45 - Bug 1870 (cherry picked from commit 9e09521e621d852ac4828f1865b4ccb01568d9ee) Signed-off-by: Phil Pennock --- diff --git a/src/src/expand.c b/src/src/expand.c index 55fb0b875..2027eb84c 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -3194,17 +3194,17 @@ items. */ while (isspace(*s)) s++; if (*s == '}') { - if (!skipping) - if (type[0] == 'i') - { - if (yes) *yieldptr = string_catn(*yieldptr, sizeptr, ptrptr, US"true", 4); - } - else - { - if (yes && lookup_value) - *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, lookup_value); - lookup_value = save_lookup; - } + if (type[0] == 'i') + { + if (yes && !skipping) + *yieldptr = string_catn(*yieldptr, sizeptr, ptrptr, US"true", 4); + } + else + { + if (yes && lookup_value && !skipping) + *yieldptr = string_cat(*yieldptr, sizeptr, ptrptr, lookup_value); + lookup_value = save_lookup; + } s++; goto RETURN; } @@ -5801,11 +5801,12 @@ while (*s != 0) processing for real, we perform the iteration. */ if (skipping) continue; - while ((iterate_item = string_nextinlist(&list, &sep, NULL, 0)) != NULL) + while ((iterate_item = string_nextinlist(&list, &sep, NULL, 0))) { *outsep = (uschar)sep; /* Separator as a string */ - DEBUG(D_expand) debug_printf_indent("%s: $item = \"%s\"\n", name, iterate_item); + DEBUG(D_expand) debug_printf_indent("%s: $item = '%s' $value = '%s'\n", + name, iterate_item, lookup_value); if (item_type == EITEM_FILTER) {