Fix expansions for RFC 822 addresses having comments in local-part and/or domain...
authorJasen Betts <jasen@xnet.co.nz>
Mon, 18 Feb 2019 13:52:16 +0000 (13:52 +0000)
committerHeiko Schlittermann (HS12-RIPE) <hs@schlittermann.de>
Mon, 2 Sep 2019 22:17:24 +0000 (00:17 +0200)
(cherry picked from commit e2ff8e24f41caca3623228b1ec66a3f3961ecad6)
(cherry picked from commit f634b80846cc7ffcab65c9855bcb35312f0232e8)
(cherry picked from commit cebd5bd2ab84c7815a9b99c0f0f16e829af7b4bc)

doc/doc-txt/ChangeLog
src/src/expand.c
test/scripts/0000-Basic/0002
test/stdout/0002

index 7adc1d6e0b831afc37e9cee733c254ee324a223b..13c2cb64bb1d5ad5029401073d59044f28e5dcc1 100644 (file)
@@ -29,6 +29,9 @@ JH/07 GnuTLS: Our use of late (post-handshake) certificate verification, under
       TLS connection attempt, so that the normal retry-in-clear can work (if
       suitably configured).
 
       TLS connection attempt, so that the normal retry-in-clear can work (if
       suitably configured).
 
+JB/01 BZg 2375: fix expansions of 822 addresses having comments in local-part
+      and/or domain.  Found and fixed by Jason Betts.
+
 
 Exim version 4.92
 -----------------
 
 Exim version 4.92
 -----------------
index c2eba072ac815474535796b08358d3944bc7b839..fbb2dfb149052144fa40a7dfaebe6060b5f5b127 100644 (file)
@@ -7151,16 +7151,11 @@ while (*s != 0)
         uschar * t = parse_extract_address(sub, &error, &start, &end, &domain,
           FALSE);
         if (t)
         uschar * t = parse_extract_address(sub, &error, &start, &end, &domain,
           FALSE);
         if (t)
-          if (c != EOP_DOMAIN)
-            {
-            if (c == EOP_LOCAL_PART && domain != 0) end = start + domain - 1;
-            yield = string_catn(yield, sub+start, end-start);
-            }
-          else if (domain != 0)
-            {
-            domain += start;
-            yield = string_catn(yield, sub+domain, end-domain);
-            }
+         yield = c == EOP_DOMAIN
+           ? string_cat(yield, t + domain)
+           : c == EOP_LOCAL_PART && domain > 0
+           ? string_catn(yield, t, domain - 1 )
+           : string_cat(yield, t);
         continue;
         }
 
         continue;
         }
 
@@ -7184,7 +7179,7 @@ while (*s != 0)
 
         for (;;)
           {
 
         for (;;)
           {
-          uschar *p = parse_find_address_end(sub, FALSE);
+          uschar * p = parse_find_address_end(sub, FALSE);
           uschar saveend = *p;
           *p = '\0';
           address = parse_extract_address(sub, &error, &start, &end, &domain,
           uschar saveend = *p;
           *p = '\0';
           address = parse_extract_address(sub, &error, &start, &end, &domain,
@@ -7197,7 +7192,7 @@ while (*s != 0)
           list, add in a space if the new address begins with the separator
           character, or is an empty string. */
 
           list, add in a space if the new address begins with the separator
           character, or is an empty string. */
 
-          if (address != NULL)
+          if (address)
             {
             if (yield->ptr != save_ptr && address[0] == *outsep)
               yield = string_catn(yield, US" ", 1);
             {
             if (yield->ptr != save_ptr && address[0] == *outsep)
               yield = string_catn(yield, US" ", 1);
index 7a9b38dba3ab1d2df5e602008876870d57598e16..1f520f671f5b9a51cc8a639f5ff7076e255ccd31 100644 (file)
@@ -123,8 +123,14 @@ acl: ${reduce {1:2:3:4} {} {$value ${acl {a_ret}{$item}}}}
 
 addrss: ${address:local-part@dom.ain}
 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
 
 addrss: ${address:local-part@dom.ain}
 addrss: ${address:Exim Person <local-part@dom.ain> (that's me)}
+addrss: ${address:Exim Person <local-part(comment)@dom.ain> (that's me)}
+addrss: ${address:Exim Person <local-part@dom.ain(comment)> (that's me)}
+addrss: ${address:Exim Person <local-part(comment)@dom.ain(comment2)> (that's me)}
+addrss: ${address:Exim Person <local-part.(comment)dot-atom@dom.ain(comment2)> (that's me)}
+addrss: ${address:Exim Person <(comment)local-part@dom.ain(comment2)> (that's me)}
 domain: ${domain:local-part@dom.ain}
 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
 domain: ${domain:local-part@dom.ain}
 domain: ${domain:Exim Person <local-part@dom.ain> (that's me)}
+domain: ${domain:Exim Person <local-part(foo)@(bar)dom.ain> (that's me)}
 
 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
 
 addresses: ${addresses:>' 'abc@xyz, 'pqr@xyz}
 addresses: ${addresses:Exim Person <local-part@dom.ain> (that's me)}
@@ -244,6 +250,7 @@ lc/uc:  ${lc:The Quick} ${uc: Brown Fox}
 length: ${length_10:The quick brown fox} ${l_10:abc}
 lclpt:  ${local_part:local-part@dom.ain}
 lclpt:  ${local_part:Exim Person <local-part@dom.ain> (that's me)}
 length: ${length_10:The quick brown fox} ${l_10:abc}
 lclpt:  ${local_part:local-part@dom.ain}
 lclpt:  ${local_part:Exim Person <local-part@dom.ain> (that's me)}
+lclpt:  ${local_part:Exim Person <local(comment).part@dom.(comment2)ain> (that's me)}
 quote:  ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
 quote:  ${quote:nl(\n)}
 quote:  ${quote:cr(\r)}
 quote:  ${quote:aZ09_.-Q} ${quote:ab*cd} ${quote:ab\cd"ef}
 quote:  ${quote:nl(\n)}
 quote:  ${quote:cr(\r)}
index c2f5f2f3c99c648dcb8cd99730b237406bcf4330..25535fc9fbfc2aa8604a5df4d67b26266b2480e3 100644 (file)
 > 
 > addrss: local-part@dom.ain
 > addrss: local-part@dom.ain
 > 
 > addrss: local-part@dom.ain
 > addrss: local-part@dom.ain
+> addrss: local-part@dom.ain
+> addrss: local-part@dom.ain
+> addrss: local-part@dom.ain
+> addrss: local-part.dot-atom@dom.ain
+> addrss: local-part@dom.ain
+> domain: dom.ain
 > domain: dom.ain
 > domain: dom.ain
 > 
 > domain: dom.ain
 > domain: dom.ain
 > 
@@ -226,6 +232,7 @@ newline     tab\134backslash ~tilde\177DEL\200\201.
 > length: The quick  abc
 > lclpt:  local-part
 > lclpt:  local-part
 > length: The quick  abc
 > lclpt:  local-part
 > lclpt:  local-part
+> lclpt:  local.part
 > quote:  aZ09_.-Q "ab*cd" "abcd\"ef"
 > quote:  "nl(\n)"
 > quote:  "cr(\r)"
 > quote:  aZ09_.-Q "ab*cd" "abcd\"ef"
 > quote:  "nl(\n)"
 > quote:  "cr(\r)"