Commit 99f80efe 99f80efee8fdde2502b31bf913d2e4b679c7f0bb by Sergey Poznyakoff

(builtin_formataddr): Fixed checking for duplicate addresses.

1 parent d4d27428
...@@ -1723,6 +1723,9 @@ builtin_formataddr (struct mh_machine *mach) ...@@ -1723,6 +1723,9 @@ builtin_formataddr (struct mh_machine *mach)
1723 { 1723 {
1724 address_t addr, dest; 1724 address_t addr, dest;
1725 size_t size; 1725 size_t size;
1726 int i;
1727 size_t num;
1728 char *buf;
1726 1729
1727 if (strobj_len (&mach->reg_str) == 0) 1730 if (strobj_len (&mach->reg_str) == 0)
1728 dest = NULL; 1731 dest = NULL;
...@@ -1735,38 +1738,27 @@ builtin_formataddr (struct mh_machine *mach) ...@@ -1735,38 +1738,27 @@ builtin_formataddr (struct mh_machine *mach)
1735 return; 1738 return;
1736 } 1739 }
1737 1740
1738 if (addrlist_lookup (mach->addrlist, addr))
1739 {
1740 address_destroy (&dest);
1741 address_destroy (&addr);
1742 return;
1743 }
1744
1745 if (rcpt_mask & RCPT_ME)
1746 address_union (&dest, addr);
1747 else
1748 {
1749 int i;
1750 size_t num;
1751 char *buf;
1752
1753 address_get_count (addr, &num); 1741 address_get_count (addr, &num);
1754 for (i = 1; i <= num; i++) 1742 for (i = 1; i <= num; i++)
1755 { 1743 {
1756 if (address_aget_email (addr, i, &buf) == 0) 1744 if (address_aget_email (addr, i, &buf) == 0)
1757 { 1745 {
1758 if (!mh_is_my_name (buf)) 1746 if ((rcpt_mask & RCPT_ME) || !mh_is_my_name (buf))
1759 { 1747 {
1760 address_t subaddr; 1748 address_t subaddr;
1761 address_get_nth (addr, i, &subaddr); 1749 address_get_nth (addr, i, &subaddr);
1750 if (!addrlist_lookup (mach->addrlist, subaddr))
1751 {
1752 list_append (mach->addrlist, subaddr);
1762 address_union (&dest, subaddr); 1753 address_union (&dest, subaddr);
1754 }
1755 else
1763 address_destroy (&subaddr); 1756 address_destroy (&subaddr);
1764 } 1757 }
1765 free (buf); 1758 free (buf);
1766 } 1759 }
1767 } 1760 }
1768 } 1761
1769 list_append (mach->addrlist, addr);
1770 if (address_to_string (dest, NULL, 0, &size) == 0) 1762 if (address_to_string (dest, NULL, 0, &size) == 0)
1771 { 1763 {
1772 strobj_realloc (&mach->reg_str, size + 1); 1764 strobj_realloc (&mach->reg_str, size + 1);
......