[exim-cvs] List separator specifiers in router/transport hea…

Top Page
Delete this message
Reply to this message
Author: Exim Git Commits Mailing List
Date:  
To: exim-cvs
Subject: [exim-cvs] List separator specifiers in router/transport headers_add/remove. Bug 1581
Gitweb: http://git.exim.org/exim.git/commitdiff/2ad7897851d62bc690844f416d4ca2fabedf9459
Commit:     2ad7897851d62bc690844f416d4ca2fabedf9459
Parent:     97f83c7a669a525a5f5964a5c0708c311673b87f
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Thu Jan 29 19:06:45 2015 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Thu Jan 29 19:06:45 2015 +0000


    List separator specifiers in router/transport headers_add/remove.  Bug 1581
---
 doc/doc-docbook/spec.xfpt    |   20 ++++++++++++++++----
 doc/doc-txt/ChangeLog        |    3 +++
 src/src/readconf.c           |   22 ++++++++++------------
 test/confs/0481              |    1 +
 test/scripts/0000-Basic/0481 |    2 ++
 5 files changed, 32 insertions(+), 16 deletions(-)


diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt
index 3e9cb73..b5133a2 100644
--- a/doc/doc-docbook/spec.xfpt
+++ b/doc/doc-docbook/spec.xfpt
@@ -17154,7 +17154,10 @@ and the discussion in chapter &<<CHAPenvironment>>&.
 .option headers_add routers list&!! unset
 .cindex "header lines" "adding"
 .cindex "router" "adding header lines"
-This option specifies a list of text headers, newline-separated,
+This option specifies a list of text headers,
+.new
+newline-separated (by default, changeable in the usual way),
+.wen
 that is associated with any addresses that are accepted by the router.
 Each item is separately expanded, at routing time.  However, this
 option has no effect when an address is just being verified. The way in which
@@ -17191,7 +17194,10 @@ avoided. The &%repeat_use%& option of the &%redirect%& router may be of help.
 .option headers_remove routers list&!! unset
 .cindex "header lines" "removing"
 .cindex "router" "removing header lines"
-This option specifies a list of text headers, colon-separated,
+This option specifies a list of text headers,
+.new
+colon-separated (by default, changeable in the usual way),
+.wen
 that is associated with any addresses that are accepted by the router.
 Each item is separately expanded, at routing time.  However, this
 option has no effect when an address is just being verified. The way in which
@@ -20238,7 +20244,10 @@ value that the router supplies, and also overriding any value associated with
 .option headers_add transports list&!! unset
 .cindex "header lines" "adding in transport"
 .cindex "transport" "header lines; adding"
-This option specifies a list of text headers, newline-separated,
+This option specifies a list of text headers,
+.new
+newline-separated (by default, changeable in the usual way),
+.wen
 which are (separately) expanded and added to the header
 portion of a message as it is transported, as described in section
 &<<SECTheadersaddrem>>&. Additional header lines can also be specified by
@@ -20263,7 +20272,10 @@ checked, since this option does not automatically suppress them.
 .option headers_remove transports list&!! unset
 .cindex "header lines" "removing"
 .cindex "transport" "header lines; removing"
-This option specifies a list of header names, colon-separated;
+This option specifies a list of header names,
+.new
+colon-separated (by default, changeable in the usual way);
+.wen
 these headers are omitted from the message as it is transported, as described
 in section &<<SECTheadersaddrem>>&. Header removal can also be specified by
 routers.
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 5b21552..7c5c7c8 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -64,6 +64,9 @@ JH/16 The spamd_address main option now supports a mixed list of local
 JH/17 Bug 68: The spamd_address main option now supports an optional
       timeout value per server.


+JH/18 Bug 1581: Router and transport options headers_add/remove can
+      now have the list separator specified.
+



 Exim version 4.85
diff --git a/src/src/readconf.c b/src/src/readconf.c
index 60df37a..31a4f2d 100644
--- a/src/src/readconf.c
+++ b/src/src/readconf.c
@@ -1597,18 +1597,16 @@ switch (type)
       }
     else if (ol->type & opt_rep_str)
       {
-      uschar sep = Ustrncmp(name, "headers_add", 11)==0 ? '\n' : ':';
-      uschar * cp;
-
-      /* Strip trailing whitespace and seperators */
-      for (cp = sptr + Ustrlen(sptr) - 1;
-      cp >= sptr && (*cp == '\n' || *cp == '\t' || *cp == ' ' || *cp == sep);
-      cp--) *cp = '\0';
-
-      if (cp >= sptr)
-    *str_target = string_copy_malloc(
-              *str_target ? string_sprintf("%s%c%s", *str_target, sep, sptr)
-                  : sptr);
+      uschar sep_o = Ustrncmp(name, "headers_add", 11)==0 ? '\n' : ':';
+      int    sep_i = -(int)sep_o;
+      uschar * list = sptr;
+      uschar * s;
+      uschar * list_o = *str_target;
+
+      while ((s = string_nextinlist(&list, &sep_i, NULL, 0)))
+    list_o = string_append_listele(list_o, sep_o, s);
+      if (list_o)
+    *str_target = string_copy_malloc(list_o);
       }
     else
       {
diff --git a/test/confs/0481 b/test/confs/0481
index b55af86..926db0f 100644
--- a/test/confs/0481
+++ b/test/confs/0481
@@ -24,6 +24,7 @@ r2:
   driver = redirect
   headers_remove = Remove-Me-Also:
   headers_remove = Remove-Me:
+  headers_remove = <; Remove-Me-Too ; Remove-Me-Too2
   data = $local_part@domain


r3:
diff --git a/test/scripts/0000-Basic/0481 b/test/scripts/0000-Basic/0481
index e1b8574..be89249 100644
--- a/test/scripts/0000-Basic/0481
+++ b/test/scripts/0000-Basic/0481
@@ -7,4 +7,6 @@ exim -odi userx
Remove-Me: this header is to be removed
Another: This is another header
Remove-Me-Also: me too!
+Remove-Me-Too: me too!
+Remove-Me-Too2: me too!
****