1 From f634b80846cc7ffcab65c9855bcb35312f0232e8 Mon Sep 17 00:00:00 2001
2 From: Jasen Betts <jasen@xnet.co.nz>
3 Date: Mon, 18 Feb 2019 13:52:16 +0000
4 Subject: [PATCH 1/5] Fix expansions for RFC 822 addresses having comments in
5 local-part and/or domain. Bug 2375
7 (cherry picked from commit e2ff8e24f41caca3623228b1ec66a3f3961ecad6)
10 src/expand.c | 19 +++++++------------
11 test/scripts/0000-Basic/0002 | 7 +++++++
12 test/stdout/0002 | 7 +++++++
13 4 files changed, 24 insertions(+), 12 deletions(-)
15 diff --git a/doc/ChangeLog b/doc/ChangeLog
16 index 867a1d8a..9659da32 100644
19 @@ -16,10 +16,13 @@ JH/07 GnuTLS: Our use of late (post-handshake) certificate verification, under
20 to the client until the first read of encrypted data (typically the
21 response to EHLO). Add detection for that case and treat it as a failed
22 TLS connection attempt, so that the normal retry-in-clear can work (if
25 +JB/01 BZg 2375: fix expansions of 822 addresses having comments in local-part
26 + and/or domain. Found and fixed by Jason Betts.
32 JH/01 Remove code calling the customisable local_scan function, unless a new
33 diff --git a/src/expand.c b/src/expand.c
34 index 2c290251..35ede718 100644
37 @@ -7071,20 +7071,15 @@ while (*s != 0)
39 int start, end, domain;
40 uschar * t = parse_extract_address(sub, &error, &start, &end, &domain,
43 - if (c != EOP_DOMAIN)
45 - if (c == EOP_LOCAL_PART && domain != 0) end = start + domain - 1;
46 - yield = string_catn(yield, sub+start, end-start);
48 - else if (domain != 0)
51 - yield = string_catn(yield, sub+domain, end-domain);
53 + yield = c == EOP_DOMAIN
54 + ? string_cat(yield, t + domain)
55 + : c == EOP_LOCAL_PART && domain > 0
56 + ? string_catn(yield, t, domain - 1 )
57 + : string_cat(yield, t);
63 @@ -7104,11 +7099,11 @@ while (*s != 0)
65 f.parse_allow_group = TRUE;
69 - uschar *p = parse_find_address_end(sub, FALSE);
70 + uschar * p = parse_find_address_end(sub, FALSE);
73 address = parse_extract_address(sub, &error, &start, &end, &domain,
76 @@ -7117,11 +7112,11 @@ while (*s != 0)
77 done in chunks by searching for the separator character. At the
78 start, unless we are dealing with the first address of the output
79 list, add in a space if the new address begins with the separator
80 character, or is an empty string. */
82 - if (address != NULL)
85 if (yield->ptr != save_ptr && address[0] == *outsep)
86 yield = string_catn(yield, US" ", 1);