From: Heiko Schlittermann (HS12-RIPE) Date: Wed, 4 Oct 2017 20:25:45 +0000 (+0200) Subject: Check for proper output separator in expanding ${addresses:STRING} (Closes 2171) X-Git-Url: https://git.exim.org/users/jgh/exim.git/commitdiff_plain/1b7cf216d933b395dee691f05becca4dd44b26f7?ds=inline;hp=81f358daccc6f759456eb1ae0f8e456a9118ca9f Check for proper output separator in expanding ${addresses:STRING} (Closes 2171) Better yet would be to force setting the output separator literally, and not after expansion of the STRING. But this would be an incompatible change. --- diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index 4a8e1d06e..c14094515 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -10118,7 +10118,15 @@ character. For example: .code ${addresses:>& Chief , sec@base.ment (dogsbody)} .endd -expands to &`ceo@up.stairs&&sec@base.ment`&. Compare the &*address*& (singular) +expands to &`ceo@up.stairs&&sec@base.ment`&. The string is expanded +first, so if the expanded string starts with >, it may change the output +separator unintentionally. This can be avoided by setting the output +separator explicitly: +.code +${addresses:>:$h_from:} +.endd + +Compare the &*address*& (singular) expansion item, which extracts the working address from a single RFC2822 address. See the &*filter*&, &*map*&, and &*reduce*& items for ways of processing lists. diff --git a/src/src/expand.c b/src/src/expand.c index 353b8ea56..67b3d65de 100644 --- a/src/src/expand.c +++ b/src/src/expand.c @@ -6797,7 +6797,13 @@ while (*s != 0) int start, end, domain; /* Not really used */ while (isspace(*sub)) sub++; - if (*sub == '>') { *outsep = *++sub; ++sub; } + if (*sub == '>') + if (*outsep = *++sub) ++sub; + else { + expand_string_message = string_sprintf("output separator " + "missing in expanding ${addresses:%s}", --sub); + goto EXPAND_FAILED; + } parse_allow_group = TRUE; for (;;) diff --git a/test/scripts/0000-Basic/0002 b/test/scripts/0000-Basic/0002 index cb0bb188f..dd9cea255 100644 --- a/test/scripts/0000-Basic/0002 +++ b/test/scripts/0000-Basic/0002 @@ -133,6 +133,7 @@ addresses: ${addresses:>+ Exim Person (that's me),\ addresses: ${addresses:Exim Person (that's me), \ xyz@abc, nullgroupname:;, group: p@q, r@s; } addresses: ${addresses:local-part@dom.ain } +addresses: ${addresses:>} escape: ${escape:B7·F2ò} excape8bit: ${escape8bit:undisturbed text\ttab\nnewline\ttab\\backslash \176tilde\177DEL\200\x81.} diff --git a/test/stdout/0002 b/test/stdout/0002 index 5593f06cc..1422289a7 100644 --- a/test/stdout/0002 +++ b/test/stdout/0002 @@ -123,6 +123,7 @@ > addresses: local-part@dom.ain+xyz@abc > addresses: local-part@dom.ain:xyz@abc:p@q:r@s > addresses: +> Failed: output separator missing in expanding ${addresses:>} > > escape: B7\267F2\362 > excape8bit: undisturbed text tab