summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/doc-docbook/spec.xfpt5
-rw-r--r--src/src/readconf.c5
-rw-r--r--src/src/route.c56
-rw-r--r--test/confs/062027
-rw-r--r--test/mail/0620.b6
-rw-r--r--test/scripts/0000-Basic/06204
6 files changed, 46 insertions, 57 deletions
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index 37ada7514..dd0439644 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -19011,13 +19011,12 @@ matters.
.cindex router variables
This option may be used multiple times on a router;
because of this the list aspect is mostly irrelevant.
-The list separator is a colon but can be changed in the
+The list separator is a semicolon but can be changed in the
usual way.
Each list-element given must be of the form $"name = value"$
and the names used must start with the string &"r_"&.
-Values containing colons should either have them doubled, or
-the entire list should be prefixed with a list-separator change.
+Values containing a list-separator should have them doubled.
When a router runs, the strings are evaluated in order,
to create variables which are added to the set associated with
the address.
diff --git a/src/src/readconf.c b/src/src/readconf.c
index b9d193554..a7cf03dd3 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -1770,7 +1770,10 @@ switch (type)
}
else if (ol->type & opt_rep_str)
{
- uschar sep_o = Ustrncmp(name, "headers_add", 11)==0 ? '\n' : ':';
+ uschar sep_o =
+ Ustrncmp(name, "headers_add", 11) == 0 ? '\n'
+ : Ustrncmp(name, "set", 3) == 0 ? ';'
+ : ':';
int sep_i = -(int)sep_o;
const uschar * list = sptr;
uschar * s;
diff --git a/src/src/route.c b/src/src/route.c
index 416effd41..b6930493f 100644
--- a/src/src/route.c
+++ b/src/src/route.c
@@ -1416,7 +1416,7 @@ set_router_vars(address_item * addr, const router_instance * r)
{
const uschar * varlist = r->set;
tree_node ** root = (tree_node **) &addr->prop.variables;
-int sep = 0;
+int sep = ';';
if (!varlist) return OK;
@@ -1433,7 +1433,11 @@ for (uschar * ele; (ele = string_nextinlist(&varlist, &sep, NULL, 0)); )
/* Variable name must exist and start "r_". */
if (!name || name[0] != 'r' || name[1] != '_' || !name[2])
+ {
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "bad router variable name '%s' in router '%s'\n", name, r->name);
return FAIL;
+ }
name += 2;
while (isspace(*assignment)) assignment++;
@@ -1690,54 +1694,12 @@ for (r = addr->start_router ? addr->start_router : routers; r; r = nextr)
router traversal. On the addr string they are held as a variable tree, so
as to maintain the post-expansion taints separate. */
- if ((yield = set_router_vars(addr, r)) != OK)
- if (yield == PASS)
- continue; /* with next router */
- else
- goto ROUTE_EXIT;
-
-#ifdef notdef
- if (r->set)
+ switch (set_router_vars(addr, r))
{
- const uschar * list = r->set;
- int sep = 0;
- for (uschar * ele; (ele = string_nextinlist(&list, &sep, NULL, 0)); )
- {
- uschar * ee;
- if (!(ee = expand_string(ele)))
- if (f.expand_string_forcedfail)
- {
- DEBUG(D_route) debug_printf("forced failure in expansion of \"%s\" "
- "(router variable): decline action taken\n", ele);
-
- /* Expand "more" if necessary; DEFER => an expansion failed */
-
- yield = exp_bool(addr, US"router", r->name, D_route,
- US"more", r->more, r->expand_more, &more);
- if (yield != OK) goto ROUTE_EXIT;
-
- if (!more)
- {
- DEBUG(D_route)
- debug_printf("\"more\"=false: skipping remaining routers\n");
- router_name = NULL;
- r = NULL;
- break;
- }
- else continue; /* With next router */
- }
- else
- {
- addr->message = string_sprintf("expansion of \"%s\" failed "
- "in %s router: %s", ele, r->name, expand_string_message);
- yield = DEFER;
- goto ROUTE_EXIT;
- }
-
- addr->prop.set = string_append_listele(addr->prop.set, ':', ee);
- }
+ case OK: break;
+ case PASS: continue; /* with next router */
+ default: goto ROUTE_EXIT;
}
-#endif
/* Finally, expand the address_data field in the router. Forced failure
behaves as if the router declined. Any other failure is more serious. On
diff --git a/test/confs/0620 b/test/confs/0620
index 15e31f1c5..7f1b69415 100644
--- a/test/confs/0620
+++ b/test/confs/0620
@@ -13,25 +13,43 @@ acl_not_smtp = not_smtp
begin acl
not_smtp:
- accept log_message = rcpt <$recipients> l <$local_part>
+ accept log_message = rcpts <$recipients> local_part <$local_part>
# ----- Routers -----
begin routers
+hide_verifies:
+ driver = accept
+ verify_only
+
alias:
driver = redirect
debug_print = DEBUG: $r_r1 $r_r2
data = b
- set = <; r_r1 = <$local_part> aaa:bbb bar=baz
+ # r_r1 checks that a variable with tainted data is ok
+ # that the default list-sep ":" is not used for this list
+ # that an '=' on the RHS is ok
+ set = r_r1 = <$local_part> aaa:bbb bar=baz
+ # r_local checks that a variable is immediately usable
set = r_local = check
errors_to = bad_$r_local
user:
driver = accept
debug_print = DEBUG: $r_r1 $r_r2
+ # r_r1 vs. r_r2 checks we can have multiple "set" options
set = r_r1 = $local_part
- set = <; r_r2 = $local_part 2a00:1940:100::ff:0:1 foo=bar
+ set = r_r2 = $local_part \
+ 2a00:1940:100::ff:0:1 \
+ foo=bar \
+ # check we can get a newline into content
+ newline=initial\n\tcont \
+ # check we can get a list-sep into content (by doubling)
+ semicolon=initial;;cont \
+ ; \
+ # r_r3 checks we can have a list as arg for a "set" option
+ r_r3 = bletch
transport = local_delivery
@@ -44,8 +62,7 @@ local_delivery:
envelope_to_add
file = DIR/test-mail/$local_part
user = CALLER
- debug_print = DEBUG: $r_r1 $r_r2
- headers_add = X-r1: <$r_r1>\nX-r2: <$r_r2>
+ headers_add = X-r1: <$r_r1>\nX-r2: <$r_r2>\nX-r3: <$r_r3>
# End
diff --git a/test/mail/0620.b b/test/mail/0620.b
index 5840bc90a..ef81a0910 100644
--- a/test/mail/0620.b
+++ b/test/mail/0620.b
@@ -4,10 +4,14 @@ Received: from CALLER by the.local.host.name with local (Exim x.yz)
(envelope-from <CALLER@test.ex>)
id 10HmaX-0005vi-00
for a@test.ex; Tue, 2 Mar 1999 09:44:33 +0000
+Subject: foo
Message-Id: <E10HmaX-0005vi-00@the.local.host.name>
From: CALLER_NAME <CALLER@test.ex>
Date: Tue, 2 Mar 1999 09:44:33 +0000
X-r1: <b>
-X-r2: <b 2a00:1940:100::ff:0:1 foo=bar>
+X-r2: <b 2a00:1940:100::ff:0:1 foo=bar newline=initial
+ cont semicolon=initial;cont>
+X-r3: <bletch>
+body
diff --git a/test/scripts/0000-Basic/0620 b/test/scripts/0000-Basic/0620
index 0f662f153..96d598834 100644
--- a/test/scripts/0000-Basic/0620
+++ b/test/scripts/0000-Basic/0620
@@ -1,2 +1,6 @@
# router variables
exim -odi a
+Subject: foo
+
+body
+****