From 7651d375b035cdfde969aaa4556b13f3caab8781 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Sun, 14 Feb 2021 19:36:36 -0800 Subject: Fix missing Subject: in some Wrap Message wrappers. --- Mailman/Handlers/WrapMessage.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Mailman/Handlers') diff --git a/Mailman/Handlers/WrapMessage.py b/Mailman/Handlers/WrapMessage.py index 0ee08cb1..3aef64a2 100644 --- a/Mailman/Handlers/WrapMessage.py +++ b/Mailman/Handlers/WrapMessage.py @@ -63,13 +63,19 @@ def process(mlist, msg, msgdata): # make a copy of the msg, then delete almost everything and set/copy # what we want. omsg = copy.deepcopy(msg) + # If CookHeaders didn't change the Subject: we need to keep it too. + # Get a fresh list. + keepers = list(KEEPERS) + if 'subject' not in [key.lower() for key in + msgdata.get('add_header', {}).keys()]: + keepers.append('subject') for key in msg.keys(): - if key.lower() not in KEEPERS: + if key.lower() not in keepers: del msg[key] msg['MIME-Version'] = '1.0' msg['Message-ID'] = Utils.unique_message_id(mlist) # Add the headers from CookHeaders. - for k, v in msgdata['add_header'].items(): + for k, v in msgdata.get('add_header', {}).items(): msg[k] = v # Are we including dmarc_wrapped_message_text? I.e., do we have text and # are we wrapping because of dmarc_moderation_action? -- cgit v1.2.3 From d2ca3472e083e435e812cbc3247cccf372cba906 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Fri, 5 Mar 2021 18:24:12 -0800 Subject: Thghten conditions for scrubbing text/plain. --- Mailman/Handlers/Scrubber.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'Mailman/Handlers') diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py index cecd11fb..16ce3b02 100644 --- a/Mailman/Handlers/Scrubber.py +++ b/Mailman/Handlers/Scrubber.py @@ -90,6 +90,9 @@ def guess_extension(ctype, ext): if ctype.lower == 'application/octet-stream': # For this type, all[0] is '.obj'. '.bin' is better. return '.bin' + if ctype.lower == 'text/plain': + # For this type, all[0] is '.ksh'. '.txt' is better. + return '.txt' return all and all[0] @@ -196,7 +199,10 @@ def process(mlist, msg, msgdata=None): format = part.get_param('format') delsp = part.get_param('delsp') # TK: if part is attached then check charset and scrub if none - if part.get('content-disposition') and \ + # MAS: Content-Disposition is not a good test for 'attached'. + # RFC 2183 sec. 2.10 allows Content-Disposition on the main body. + # Make it specifically 'attachment'. + if part.get('content-disposition').lower() == 'attachment' and \ not part.get_content_charset(): omask = os.umask(002) try: -- cgit v1.2.3 From 416d2e6ef003869486dcf6d212133511114767be Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Sat, 6 Mar 2021 11:11:23 -0800 Subject: Fix bug in prior commit. --- Mailman/Handlers/Scrubber.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Mailman/Handlers') diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py index 16ce3b02..a498f814 100644 --- a/Mailman/Handlers/Scrubber.py +++ b/Mailman/Handlers/Scrubber.py @@ -202,8 +202,8 @@ def process(mlist, msg, msgdata=None): # MAS: Content-Disposition is not a good test for 'attached'. # RFC 2183 sec. 2.10 allows Content-Disposition on the main body. # Make it specifically 'attachment'. - if part.get('content-disposition').lower() == 'attachment' and \ - not part.get_content_charset(): + if (part.get('content-disposition', '').lower() == 'attachment' + and not part.get_content_charset()): omask = os.umask(002) try: url = save_attachment(mlist, part, dir) -- cgit v1.2.3