Check for proper output separator in expanding ${addresses:STRING} (Closes 2171)
authorHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Wed, 4 Oct 2017 20:25:45 +0000 (22:25 +0200)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Fri, 6 Oct 2017 19:46:34 +0000 (21:46 +0200)
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.

doc/doc-docbook/spec.xfpt
src/src/expand.c
test/scripts/0000-Basic/0002
test/stdout/0002

index 4a8e1d0..c140945 100644 (file)
@@ -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.
index 353b8ea..67b3d65 100644 (file)
@@ -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 (;;)
index cb0bb18..dd9cea2 100644 (file)
@@ -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.}
index 5593f06..1422289 100644 (file)
 > 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