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 4a8e1d06e39b4f5945d6e23bd634c13984fd729f..c14094515c78acc20952e7ea736ffd3a969e6db9 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 353b8ea56b6cdb6a19f0226d826b681bd9254e72..67b3d65de43108090c7837e9a6c673fc2b7ec5fe 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 cb0bb188fadc388e81d20d8b236dc3dd79f69d54..dd9cea25532d2e5379ce8da9462470281c08669c 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 5593f06cc20cf39818b6c70f082bb02b1cf4a1db..1422289a759a796d2c77e018bdce573581e93c75 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