On 5/26/20 12:33 AM, Alan So wrote:
Thanks. Just filed an issue: https://gitlab.com/mailman/mailman/-/issues/725
Thank you for your "well formed" issue. I have started to work on this, but I have run into a snag.
The patch at <https://lists.mailman3.org/archives/list/mailman-users@mailman3.org/message/Y6DCI4Z2J57K5577MGFXUEUXXQVOIOBE/attachment/2/avoid_duplicates_patch.txt> doesn't work. The problem is msg.get_all(header, []) does not parse the header and return a list of addresses. It just returns a list, the items of which are the raw values if the header instances in msg. I.e., if there is only one Cc: header, msg.get_all('cc', []) returns a list of one string which is the raw value of that header. If there were two Cc: headers in the message it would return a list of two strings with the two raw values.
Thus, we would need to parse the strings returned into the individual email addresses. The simple minded way to do that is
addrs = []
for hdr in msg.get_all(header, []):
for addr in hdr.split(','):
addrs.append(parseaddr(re.sub('[\r\n]', '', addr)))
but that will fail if the header contains a quoted display name containing a comma such as
"last, first" <user@example.com>
So, I need to go back to using getaddresses, but do the unfolding first. Watch the issue for the final fix.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan