summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/doc-docbook/spec.xfpt10
-rw-r--r--src/src/expand.c8
-rw-r--r--test/scripts/0000-Basic/00021
-rw-r--r--test/stdout/00021
4 files changed, 18 insertions, 2 deletions
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 <ceo@up.stairs>, 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 <local-part@dom.ain> (that's me),\
addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me), \
xyz@abc, nullgroupname:;, group: p@q, r@s; }
addresses: ${addresses:local-part@dom.ain <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