From b1b05573117d62c3b95d854d8ac5a447df19e82e Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 4 Oct 2012 22:21:09 +0100 Subject: Strip leading/trailing newlines on list of headers for addition; bug 884. NB: this means a bare "X-ACL-Warn:" header is harder to add. --- src/src/acl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/src/acl.c b/src/src/acl.c index 3b23a915b..f9a32d3b7 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -958,10 +958,13 @@ setup_header(uschar *hstring) uschar *p, *q; int hlen = Ustrlen(hstring); -/* An empty string does nothing; otherwise add a final newline if necessary. */ +/* Ignore any leading newlines */ +while (*hstring == '\n') hstring++, hlen--; +/* An empty string does nothing; ensure exactly one final newline. */ if (hlen <= 0) return; -if (hstring[hlen-1] != '\n') hstring = string_sprintf("%s\n", hstring); +if (hstring[--hlen] != '\n') hstring = string_sprintf("%s\n", hstring); +else while(hstring[--hlen] == '\n') hstring[hlen+1] = '\0'; /* Loop for multiple header lines, taking care about continuations */ -- cgit v1.2.3